Sha256: 6340a979c008691625b237f55494213d8b532d04175ede7ba5fb23b693647f8a

Contents?: true

Size: 1.27 KB

Versions: 13

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Decidim
  module Core
    class ComponentInputSort < BaseInputSort
      include HasLocalizedInputSort

      graphql_name "ComponentSort"
      description "A type used for sorting any component parent objects"

      argument :id, GraphQL::Types::String, "Sort by ID, valid values are ASC or DESC", required: false
      argument :weight, GraphQL::Types::String, "Sort by weight (order in the website), valid values are ASC or DESC", required: false
      argument :type,
               type: GraphQL::Types::String,
               description: "Sort by type of component, alphabetically, valid values are ASC or DESC",
               required: false,
               as: :manifest_name
      argument :name,
               type: GraphQL::Types::String,
               description: "Sort by name of the component, alphabetically, valid values are ASC or DESC",
               required: false,
               as: :name,
               prepare: lambda { |direction, ctx|
                          lambda { |locale|
                            locale = ctx[:current_organization].default_locale if locale.blank?
                            [Arel.sql("name->? #{direction.upcase}"), locale]
                          }
                        }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.25.2 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.25.1 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.25.0 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.25.0.rc4 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.25.0.rc3 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.25.0.rc2 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.25.0.rc1 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.24.3 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.24.2 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.24.1 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.24.0 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.24.0.rc2 lib/decidim/api/input_sorts/component_input_sort.rb
decidim-core-0.24.0.rc1 lib/decidim/api/input_sorts/component_input_sort.rb