Class: SolidusAdmin::Orders::Index::Component
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- SolidusAdmin::Orders::Index::Component
- Defined in:
- app/components/solidus_admin/orders/index/component.rb
Instance Method Summary collapse
- #batch_actions ⇒ Object
- #columns ⇒ Object
- #customer_column ⇒ Object
- #date_column ⇒ Object
- #filters ⇒ Object
-
#initialize(page:) ⇒ Component
constructor
A new instance of Component.
- #items_column ⇒ Object
- #next_page_link ⇒ Object
- #number_column ⇒ Object
- #payment_column ⇒ Object
- #prev_page_link ⇒ Object
- #shipment_column ⇒ Object
- #title ⇒ Object
- #total_column ⇒ Object
Constructor Details
#initialize(page:) ⇒ Component
Returns a new instance of Component.
4 5 6 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 4 def initialize(page:) @page = page end |
Instance Method Details
#batch_actions ⇒ Object
22 23 24 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 22 def batch_actions [] end |
#columns ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 36 def columns [ number_column, date_column, customer_column, total_column, items_column, payment_column, shipment_column, ] end |
#customer_column ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 72 def customer_column { class_name: "w-[400px]", header: :customer, data: ->(order) do customer_email = order.user&.email content_tag :div, String(customer_email) end } end |
#date_column ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 63 def date_column { header: :date, data: ->(order) do content_tag :div, l(order.created_at, format: :short) end } end |
#filters ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 26 def filters [ { name: 'q[completed_at_not_null]', value: 1, label: t('.filters.only_show_complete_orders'), }, ] end |
#items_column ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 92 def items_column { header: :items, data: ->(order) do content_tag :div, t('.columns.items', count: order.line_items.sum(:quantity)) end } end |
#next_page_link ⇒ Object
18 19 20 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 18 def next_page_link @page.last? ? nil : solidus_admin.url_for(host: request.host, port: request.port, **request.params, page: @page.next_param) end |
#number_column ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 48 def number_column { header: :order, data: ->(order) do order_path = spree.edit_admin_order_path(order) if !fade_row_proc.call(order) link_to order.number, order_path, class: 'font-semibold' else link_to order.number, order_path end end } end |
#payment_column ⇒ Object
101 102 103 104 105 106 107 108 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 101 def payment_column { header: :payment, data: ->(order) do component('ui/badge').new(name: order.payment_state&.humanize, color: order.paid? ? :green : :yellow) end } end |
#prev_page_link ⇒ Object
14 15 16 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 14 def prev_page_link @page.first? ? nil : solidus_admin.url_for(host: request.host, port: request.port, **request.params, page: @page.number - 1) end |
#shipment_column ⇒ Object
110 111 112 113 114 115 116 117 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 110 def shipment_column { header: :shipment, data: ->(order) do component('ui/badge').new(name: order.shipment_state&.humanize, color: order.shipped? ? :green : :yellow) end } end |
#title ⇒ Object
10 11 12 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 10 def title Spree::Order.model_name.human.pluralize end |
#total_column ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'app/components/solidus_admin/orders/index/component.rb', line 83 def total_column { header: :total, data: ->(order) do content_tag :div, number_to_currency(order.total) end } end |