mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
Implement full_name_for_sorting
This commit is contained in:
@@ -4,4 +4,8 @@ module AddressDisplay
|
||||
def full_name_reverse
|
||||
[lastname, firstname].reject(&:blank?).join(" ")
|
||||
end
|
||||
|
||||
def full_name_for_sorting
|
||||
[last_name, first_name].reject(&:blank?).join(", ")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
module Api
|
||||
module Admin
|
||||
class OrderSerializer < ActiveModel::Serializer
|
||||
attributes :id, :number, :user_id, :full_name, :first_name, :last_name, :email, :phone,
|
||||
include AddressDisplay
|
||||
|
||||
attributes :id, :number, :user_id, :full_name, :full_name_for_sorting, :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,
|
||||
@@ -18,11 +20,11 @@ module Api
|
||||
end
|
||||
|
||||
def first_name
|
||||
object.billing_address.nil? ? "" : ( object.billing_address.first_name || "" )
|
||||
object.billing_address&.first_name || ""
|
||||
end
|
||||
|
||||
def last_name
|
||||
object.billing_address.nil? ? "" : ( object.billing_address.last_name || "" )
|
||||
object.billing_address&.last_name || ""
|
||||
end
|
||||
|
||||
def distributor_name
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
%a{ :href => '', 'ng-click' => "sorting.toggle('order.number')" }
|
||||
= t("admin.orders.bulk_management.order_no")
|
||||
%th.full_name{ 'ng-show' => 'columns.full_name.visible' }
|
||||
%a{ :href => '', 'ng-click' => "sorting.toggle(['order.last_name', 'order.first_name'])" }
|
||||
%a{ :href => '', 'ng-click' => "sorting.toggle('order.full_name_for_sorting')" }
|
||||
= t("admin.name")
|
||||
%th.email{ 'ng-show' => 'columns.email.visible' }
|
||||
%a{ :href => '', 'ng-click' => "sorting.toggle('order.email')" }
|
||||
@@ -170,7 +170,7 @@
|
||||
%td.bulk
|
||||
%input{ :type => "checkbox", :name => 'bulk', 'ng-model' => 'line_item.checked', 'ignore-dirty' => true }
|
||||
%td.order_no{ 'ng-show' => 'columns.order_no.visible' } {{ line_item.order.number }}
|
||||
%td.full_name{ 'ng-show' => 'columns.full_name.visible' } {{ line_item.order.last_name + ', ' + line_item.order.first_name }}
|
||||
%td.full_name{ 'ng-show' => 'columns.full_name.visible' } {{ line_item.order.full_name_for_sorting }}
|
||||
%td.email{ 'ng-show' => 'columns.email.visible' } {{ line_item.order.email }}
|
||||
%td.phone{ 'ng-show' => 'columns.phone.visible' } {{ line_item.order.phone }}
|
||||
%td.date{ 'ng-show' => 'columns.order_date.visible' } {{ line_item.order.completed_at }}
|
||||
|
||||
Reference in New Issue
Block a user