Sha256: 9bbfdc519eae80289fbdcaaa8965dd8e52b538eb88e1338f5519cb41279c7d6f

Contents?: true

Size: 1.01 KB

Versions: 37

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Decidim
  module Core
    # An abstract base class resolver for the GraphQL endpoint for listing participatory spaces
    # Inherit from this class and add search arguments to create list-finders participatory classes
    # as is shown in ParticipatorySpaceList
    # + info:
    # https://github.com/rmosolgo/graphql-ruby/blob/v1.6.8/guides/fields/function.md
    class ParticipatorySpaceListBase
      include NeedsApiFilterAndOrder
      include NeedsApiDefaultOrder
      attr_reader :manifest

      def initialize(manifest:)
        @manifest = manifest
      end

      # lazy instantation of the class
      def model_class
        @model_class ||= manifest.model_class_name.constantize
      end

      def call(_obj, args, ctx)
        @query = model_class.public_spaces.where(
          organization: ctx[:current_organization]
        )

        add_filter_keys(args[:filter])
        add_order_keys(args[:order].to_h)
        add_default_order
        @query
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
decidim-core-0.27.9 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.8 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.7 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.6 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.26.10 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.26.9 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.5 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.26.8 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.4 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.3 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.26.7 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.26.5 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.2 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.1 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.26.4 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.0 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.26.3 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.0.rc2 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.27.0.rc1 lib/decidim/api/functions/participatory_space_list_base.rb
decidim-core-0.26.2 lib/decidim/api/functions/participatory_space_list_base.rb