avo-hq/avo

Add option to configure via_per_page on has_many

Open

#2.661 geöffnet am 4. Apr. 2024

Auf GitHub ansehen
 (8 Kommentare) (2 Reaktionen) (1 zugewiesene Person)Ruby (308 Forks)user submission
ConfigurationEnhancementHelp wanted

Repository-Metriken

Stars
 (1.778 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 6h) (67 gemergte PRs in 30 T)

Beschreibung

Feature

Currently, it seems only possible to set a global via_per_page.

It would be useful to have the ability to override that value in the resource itself.

API could be something like:

module Avo
  module Resources
    class CatalogProduct < Avo::BaseResource
      def fields
         field :certifications, as: :has_many, per_page: 72
      end
  end
end

or alternatively, we could default it per resource.

module Avo
  module Resources
    class CatalogCertification < Avo::BaseResource
      self.via_per_page = 72
      self.per_page = 24
      def fields
        # ...
      end
  end
end

This is useful because in most case, we want a smaller pagination window, but we do have a few workflows where it's useful to see a large amount of items for triggering action on a batch of records.

Current workarounds

Not aware of any

Screenshots or screen recordings

Additional context

Contributor Guide