fix: Contacts page sort by created_at [CW-2262] (#7584)
Fixes the contacts page sort by created_at. fixes: #7577
This commit is contained in:
@@ -4,6 +4,7 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
|
|||||||
sort_on :name, internal_name: :order_on_name, type: :scope, scope_params: [:direction]
|
sort_on :name, internal_name: :order_on_name, type: :scope, scope_params: [:direction]
|
||||||
sort_on :phone_number, type: :string
|
sort_on :phone_number, type: :string
|
||||||
sort_on :last_activity_at, internal_name: :order_on_last_activity_at, type: :scope, scope_params: [:direction]
|
sort_on :last_activity_at, internal_name: :order_on_last_activity_at, type: :scope, scope_params: [:direction]
|
||||||
|
sort_on :created_at, internal_name: :order_on_created_at, type: :scope, scope_params: [:direction]
|
||||||
sort_on :company, internal_name: :order_on_company_name, type: :scope, scope_params: [:direction]
|
sort_on :company, internal_name: :order_on_company_name, type: :scope, scope_params: [:direction]
|
||||||
sort_on :city, internal_name: :order_on_city, type: :scope, scope_params: [:direction]
|
sort_on :city, internal_name: :order_on_city, type: :scope, scope_params: [:direction]
|
||||||
sort_on :country, internal_name: :order_on_country_name, type: :scope, scope_params: [:direction]
|
sort_on :country, internal_name: :order_on_country_name, type: :scope, scope_params: [:direction]
|
||||||
|
|||||||
@@ -62,6 +62,14 @@ class Contact < ApplicationRecord
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
scope :order_on_created_at, lambda { |direction|
|
||||||
|
order(
|
||||||
|
Arel::Nodes::SqlLiteral.new(
|
||||||
|
sanitize_sql_for_order("\"contacts\".\"created_at\" #{direction}
|
||||||
|
NULLS LAST")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
scope :order_on_company_name, lambda { |direction|
|
scope :order_on_company_name, lambda { |direction|
|
||||||
order(
|
order(
|
||||||
Arel::Nodes::SqlLiteral.new(
|
Arel::Nodes::SqlLiteral.new(
|
||||||
|
|||||||
Reference in New Issue
Block a user