summaryrefslogtreecommitdiff
path: root/app/graphql/types/customer_relations/contact_sort_enum.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/types/customer_relations/contact_sort_enum.rb')
-rw-r--r--app/graphql/types/customer_relations/contact_sort_enum.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/graphql/types/customer_relations/contact_sort_enum.rb b/app/graphql/types/customer_relations/contact_sort_enum.rb
new file mode 100644
index 00000000000..221dedacb6a
--- /dev/null
+++ b/app/graphql/types/customer_relations/contact_sort_enum.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+module Types
+ module CustomerRelations
+ class ContactSortEnum < SortEnum
+ graphql_name 'ContactSort'
+ description 'Values for sorting contacts'
+
+ sortable_fields = ['First name', 'Last name', 'Email', 'Phone', 'Description', 'Organization']
+
+ sortable_fields.each do |field|
+ value "#{field.upcase.tr(' ', '_')}_ASC",
+ value: { field: field.downcase.tr(' ', '_'), direction: :asc },
+ description: "#{field} by ascending order."
+ value "#{field.upcase.tr(' ', '_')}_DESC",
+ value: { field: field.downcase.tr(' ', '_'), direction: :desc },
+ description: "#{field} by descending order."
+ end
+ end
+ end
+end