Sha256: 4854fbea457de7f4752d9aa57d216e4236028cc54c077691bc0461f67b912a37

Contents?: true

Size: 1.25 KB

Versions: 10

Compression:

Stored size: 1.25 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, String, "Sort by ID, valid values are ASC or DESC", required: false
      argument :weight, String, "Sort by weight (order in the website), valid values are ASC or DESC", required: false
      argument :type,
               type: String,
               description: "Sort by type of component, alphabetically, valid values are ASC or DESC",
               required: false,
               prepare: ->(direction, _ctx) do
                 { manifest_name: direction }
               end
      argument :name,
               type: String,
               description: "Sort by name of the component, alphabetically, valid values are ASC or DESC",
               required: false,
               prepare: ->(direction, ctx) do
                          proc do |locale|
                            locale = ctx[:current_organization].default_locale if locale.blank?
                            [Arel.sql("name->? #{direction.upcase}"), locale]
                          end
                        end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-core-0.23.6 app/types/decidim/core/component_input_sort.rb
decidim-core-0.23.5 app/types/decidim/core/component_input_sort.rb
decidim-core-0.23.4 app/types/decidim/core/component_input_sort.rb
decidim-core-0.23.3 app/types/decidim/core/component_input_sort.rb
decidim-core-0.23.2 app/types/decidim/core/component_input_sort.rb
decidim-core-0.23.1 app/types/decidim/core/component_input_sort.rb
decidim-core-0.23.1.rc1 app/types/decidim/core/component_input_sort.rb
decidim-core-0.23.0 app/types/decidim/core/component_input_sort.rb
decidim-core-0.22.0 app/types/decidim/core/component_input_sort.rb
decidim-core-0.21.0 app/types/decidim/core/component_input_sort.rb