Class: SolidusAdmin::Users::Orders::Component
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- SolidusAdmin::Users::Orders::Component
- Includes:
- Layout::PageHelpers
- Defined in:
- app/components/solidus_admin/users/orders/component.rb
Instance Method Summary collapse
- #columns ⇒ Object
- #date_column ⇒ Object
-
#initialize(user:, orders:) ⇒ Component
constructor
A new instance of Component.
- #model_class ⇒ Object
- #number_column ⇒ Object
- #payment_column ⇒ Object
- #row_fade(_order) ⇒ Object
- #row_url(order) ⇒ Object
- #rows ⇒ Object
- #shipment_column ⇒ Object
- #state_column ⇒ Object
- #tabs ⇒ Object
- #total_column ⇒ Object
Constructor Details
#initialize(user:, orders:) ⇒ Component
Returns a new instance of Component.
6 7 8 9 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 6 def initialize(user:, orders:) @user = user @orders = orders end |
Instance Method Details
#columns ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 57 def columns [ number_column, state_column, date_column, payment_column, shipment_column, total_column, ] end |
#date_column ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 96 def date_column { header: :date, data: ->(order) do content_tag :div, l(order.created_at, format: :short) end } end |
#model_class ⇒ Object
41 42 43 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 41 def model_class Spree::Order end |
#number_column ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 68 def number_column { header: :order, data: ->(order) do if !row_fade(order) content_tag :div, order.number, class: 'font-semibold' else content_tag :div, order.number end end } end |
#payment_column ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 114 def payment_column { header: :payment, data: ->(order) do component('ui/badge').new(name: order.payment_state.humanize, color: order.paid? ? :green : :yellow) if order.payment_state? end } end |
#row_fade(_order) ⇒ Object
53 54 55 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 53 def row_fade(_order) false end |
#row_url(order) ⇒ Object
45 46 47 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 45 def row_url(order) spree.edit_admin_order_path(order) end |
#rows ⇒ Object
49 50 51 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 49 def rows @orders end |
#shipment_column ⇒ Object
123 124 125 126 127 128 129 130 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 123 def shipment_column { header: :shipment, data: ->(order) do component('ui/badge').new(name: order.shipment_state.humanize, color: order.shipped? ? :green : :yellow) if order.shipment_state? end } end |
#state_column ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 81 def state_column { header: :state, data: ->(order) do color = { 'complete' => :green, 'returned' => :red, 'canceled' => :blue, 'cart' => :graphite_light, }[order.state] || :yellow component('ui/badge').new(name: order.state.humanize, color: color) end } end |
#tabs ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 11 def tabs [ { text: t('.account'), href: solidus_admin.user_path(@user), current: false, }, { text: t('.addresses'), href: solidus_admin.addresses_user_path(@user), current: false, }, { text: t('.order_history'), href: solidus_admin.orders_user_path(@user), current: true, }, { text: t('.items'), href: spree.items_admin_user_path(@user), current: false, }, { text: t('.store_credit'), href: spree.admin_user_store_credits_path(@user), current: false, }, ] end |
#total_column ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'app/components/solidus_admin/users/orders/component.rb', line 105 def total_column { header: :total, data: ->(order) do content_tag :div, number_to_currency(order.total) end } end |