Class: SolidusAdmin::Orders::Show::Adjustments::Index::Component
- Inherits:
-
UI::Pages::Index::Component
- Object
- UI::Pages::Index::Component
- SolidusAdmin::Orders::Show::Adjustments::Index::Component
- Defined in:
- app/components/solidus_admin/orders/show/adjustments/index/component.rb
Constant Summary collapse
- NBSP =
" ".html_safe
Instance Method Summary collapse
- #back_url ⇒ Object
- #batch_actions ⇒ Object
- #columns ⇒ Object
-
#initialize(order:, adjustments:) ⇒ Component
constructor
A new instance of Component.
- #model_class ⇒ Object
- #search_key ⇒ Object
- #search_url ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(order:, adjustments:) ⇒ Component
Returns a new instance of Component.
18 19 20 21 22 |
# File 'app/components/solidus_admin/orders/show/adjustments/index/component.rb', line 18 def initialize(order:, adjustments:) @order = order @adjustments = adjustments @page = GearedPagination::Recordset.new(adjustments, per_page: adjustments.size).page(1) end |
Instance Method Details
#back_url ⇒ Object
8 9 10 |
# File 'app/components/solidus_admin/orders/show/adjustments/index/component.rb', line 8 def back_url solidus_admin.order_path(@order) end |
#batch_actions ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/solidus_admin/orders/show/adjustments/index/component.rb', line 24 def batch_actions [ { label: t(".actions.lock"), action: solidus_admin.lock_order_adjustments_path(@order), method: :put, icon: "lock-line" }, { label: t(".actions.unlock"), action: solidus_admin.unlock_order_adjustments_path(@order), method: :put, icon: "lock-unlock-line" }, { label: t(".actions.delete"), action: spree.admin_order_adjustment_path(@order, '[]'), method: :delete, icon: "delete-bin-7-line" }, ] end |
#columns ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'app/components/solidus_admin/orders/show/adjustments/index/component.rb', line 55 def columns [ { header: :state, wrap: true, col: { class: 'w-[calc(5rem+2rem+2.5rem+1px)]' }, data: ->(adjustment) { if adjustment.finalized? icon = 'lock-fill' title = t(".state.locked") else icon = 'lock-unlock-line' title = t(".state.unlocked") end icon_tag(icon, class: "w-5 h-5 align-middle") + tag.span(title) } }, { header: :adjustable, col: { class: 'w-56' }, data: ->(adjustment) { (adjustment, :adjustable) } }, { header: :source, col: { class: "w-56" }, data: ->(adjustment) { (adjustment, :source) } }, { header: :amount, col: { class: 'w-24' }, data: ->(adjustment) { tag.span adjustment.display_amount.to_html, class: "grow text-right whitespace-nowrap" } }, { header: tag.span(t(".actions.title"), class: 'sr-only'), col: { class: 'w-24' }, wrap: false, data: ->(adjustment) do actions = [] unless adjustment.source actions << link_to( t(".actions.edit"), spree.edit_admin_order_adjustment_path(@order, adjustment), class: 'body-link', ) end if adjustment.finalized? actions << link_to( t(".actions.unlock"), solidus_admin.unlock_order_adjustments_path(@order, id: adjustment), "data-turbo-method": :put, "data-turbo-confirm": t('.confirm'), class: 'body-link', ) else actions << link_to( t(".actions.lock"), solidus_admin.lock_order_adjustments_path(@order, id: adjustment), "data-turbo-method": :put, "data-turbo-confirm": t('.confirm'), class: 'body-link', ) actions << link_to( t(".actions.delete"), spree.admin_order_adjustment_path(@order, adjustment), "data-turbo-method": :delete, "data-turbo-confirm": t('.confirm'), class: 'body-link !text-red-500', ) end render component('ui/dropdown').new( direction: :right, class: 'relative w-fit m-auto', ).with_content(safe_join(actions)) end }, ] end |
#model_class ⇒ Object
4 5 6 |
# File 'app/components/solidus_admin/orders/show/adjustments/index/component.rb', line 4 def model_class Spree::Adjustment end |
#search_key ⇒ Object
47 48 49 |
# File 'app/components/solidus_admin/orders/show/adjustments/index/component.rb', line 47 def search_key :label_cont end |
#search_url ⇒ Object
51 52 53 |
# File 'app/components/solidus_admin/orders/show/adjustments/index/component.rb', line 51 def search_url solidus_admin.order_adjustments_path(@order) end |
#title ⇒ Object
12 13 14 |
# File 'app/components/solidus_admin/orders/show/adjustments/index/component.rb', line 12 def title t(".title", number: @order.number) end |