diff options
Diffstat (limited to 'app/graphql/types/customer_relations')
4 files changed, 53 insertions, 4 deletions
diff --git a/app/graphql/types/customer_relations/contact_sort_enum.rb b/app/graphql/types/customer_relations/contact_sort_enum.rb index 221dedacb6a..bb11d741368 100644 --- a/app/graphql/types/customer_relations/contact_sort_enum.rb +++ b/app/graphql/types/customer_relations/contact_sort_enum.rb @@ -11,10 +11,10 @@ module Types sortable_fields.each do |field| value "#{field.upcase.tr(' ', '_')}_ASC", value: { field: field.downcase.tr(' ', '_'), direction: :asc }, - description: "#{field} by ascending order." + description: "#{field} in ascending order." value "#{field.upcase.tr(' ', '_')}_DESC", value: { field: field.downcase.tr(' ', '_'), direction: :desc }, - description: "#{field} by descending order." + description: "#{field} in descending order." end end end diff --git a/app/graphql/types/customer_relations/organization_sort_enum.rb b/app/graphql/types/customer_relations/organization_sort_enum.rb new file mode 100644 index 00000000000..742a5a4fa99 --- /dev/null +++ b/app/graphql/types/customer_relations/organization_sort_enum.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Types + module CustomerRelations + class OrganizationSortEnum < SortEnum + graphql_name 'OrganizationSort' + description 'Values for sorting organizations' + + sortable_fields = ['Name', 'Description', 'Default Rate'] + + sortable_fields.each do |field| + value "#{field.upcase.tr(' ', '_')}_ASC", + value: { field: field.downcase.tr(' ', '_'), direction: :asc }, + description: "#{field} in ascending order." + value "#{field.upcase.tr(' ', '_')}_DESC", + value: { field: field.downcase.tr(' ', '_'), direction: :desc }, + description: "#{field} in descending order." + end + end + end +end diff --git a/app/graphql/types/customer_relations/organization_state_counts_type.rb b/app/graphql/types/customer_relations/organization_state_counts_type.rb new file mode 100644 index 00000000000..7d813209a8e --- /dev/null +++ b/app/graphql/types/customer_relations/organization_state_counts_type.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Types + module CustomerRelations + # `object` is a hash. Authorization is performed by OrganizationStateCountsResolver + class OrganizationStateCountsType < Types::BaseObject # rubocop:disable Graphql/AuthorizeTypes + graphql_name 'OrganizationStateCounts' + description 'Represents the total number of organizations for the represented states.' + + AVAILABLE_STATES = ::CustomerRelations::Organization.states.keys.push('all').freeze + + AVAILABLE_STATES.each do |state| + field state, + GraphQL::Types::Int, + null: true, + description: "Number of organizations with state `#{state.upcase}`" + end + + def all + object.values.sum + end + end + end +end diff --git a/app/graphql/types/customer_relations/organization_state_enum.rb b/app/graphql/types/customer_relations/organization_state_enum.rb index ecdd7d092ad..84bbbbc90fc 100644 --- a/app/graphql/types/customer_relations/organization_state_enum.rb +++ b/app/graphql/types/customer_relations/organization_state_enum.rb @@ -5,12 +5,16 @@ module Types class OrganizationStateEnum < BaseEnum graphql_name 'CustomerRelationsOrganizationState' + value 'all', + description: "All available organizations.", + value: :all + value 'active', - description: "Active organization.", + description: "Active organizations.", value: :active value 'inactive', - description: "Inactive organization.", + description: "Inactive organizations.", value: :inactive end end |