Sort correctly in Bulk Order Managment

Converting date to utc + iso8601 format is
    sufficient to ensure proper sorting.
This commit is contained in:
cyrillefr
2023-02-20 21:41:58 +01:00
parent e3fa933699
commit c015b2066f
2 changed files with 7 additions and 2 deletions

View File

@@ -3,7 +3,8 @@
module Api
module Admin
class OrderSerializer < ActiveModel::Serializer
attributes :id, :number, :user_id, :full_name, :email, :phone, :completed_at, :display_total,
attributes :id, :number, :user_id, :full_name, :email, :phone, :completed_at,
:completed_at_utc_iso8601, :display_total,
:edit_path, :state, :payment_state, :shipment_state,
:payments_path, :ready_to_ship, :ready_to_capture, :created_at,
:distributor_name, :special_instructions, :display_outstanding_balance,
@@ -73,6 +74,10 @@ module Api
object.line_items.count
end
def completed_at_utc_iso8601
object.completed_at.blank? ? "" : object.completed_at.utc.iso8601
end
private
def spree_routes_helper

View File

@@ -138,7 +138,7 @@
%a{ :href => '', 'ng-click' => "sorting.toggle('order.phone')" }
= t("admin.phone")
%th.date{ 'ng-show' => 'columns.order_date.visible' }
%a{ :href => '', 'ng-click' => "sorting.toggle('order.completed_at')" }
%a{ :href => '', 'ng-click' => "sorting.toggle('order.completed_at_utc_iso8601')" }
= t("admin.orders.bulk_management.order_date")
%th.producer{ 'ng-show' => 'columns.producer.visible' }
%a{ :href => '', 'ng-click' => "sorting.toggle('supplier.name')" }