|
1 | | -<div |
2 | | - data-controller="<%= stimulus_id %>" |
3 | | - data-<%= stimulus_id %>-initial-count-on-hand-value="<%= @stock_item.count_on_hand_was || @stock_item.count_on_hand %>" |
4 | | - data-action="input-><%= stimulus_id %>#updateCountOnHand" |
5 | | -> |
6 | | - <%= turbo_frame_tag :edit_stock_item_modal do %> |
7 | | - <%= render component("ui/modal").new(title: t(".title")) do |modal| %> |
8 | | - <%= form_for @stock_item, url: solidus_admin.stock_item_path(@stock_item), html: { id: form_id } do |f| %> |
9 | | - <div class="flex flex-col gap-6 pb-4"> |
10 | | - <div class="flex gap-4"> |
11 | | - <%= link_to spree.edit_admin_product_variant_path( |
12 | | - @stock_item.variant.product, |
13 | | - @stock_item.variant, |
14 | | - ), class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %> |
15 | | - <%= render component("ui/resource_item").new( |
16 | | - thumbnail: |
17 | | - ( |
18 | | - @stock_item.variant.images.first || |
19 | | - @stock_item.variant.product.gallery.images.first |
20 | | - )&.url(:small), |
21 | | - title: @stock_item.variant.name, |
22 | | - subtitle: |
23 | | - "#{@stock_item.variant.sku}#{@stock_item.variant.options_text.presence&.prepend(" - ")}", |
24 | | - ) %> |
25 | | - <% end %> |
26 | | - <%= link_to spree.edit_admin_stock_location_path(@stock_item.stock_location), class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %> |
27 | | - <%= render component("ui/resource_item").new( |
28 | | - title: @stock_item.stock_location.name, |
29 | | - subtitle: "#{Spree::StockLocation.model_name.human} #{@stock_item.stock_location.code}", |
30 | | - ) %> |
31 | | - <% end %> |
32 | | - </div> |
33 | | - |
34 | | - <%= render component("ui/forms/field").text_field( |
35 | | - f, |
36 | | - :count_on_hand, |
37 | | - disabled: true, |
38 | | - value: @stock_item.count_on_hand_was || @stock_item.count_on_hand, |
39 | | - "data-#{stimulus_id}-target": 'countOnHand', |
40 | | - ) %> |
41 | | - <%= render component("ui/forms/field").new( |
42 | | - label: t(".quantity_adjustment"), |
43 | | - hint: t(".quantity_adjustment_hint_html"), |
44 | | - ) do %> |
45 | | - <%= render component("ui/forms/input").new( |
46 | | - value: params[:quantity_adjustment] || 0, |
47 | | - name: :quantity_adjustment, |
48 | | - type: :number, |
49 | | - step: 1, |
50 | | - "data-#{stimulus_id}-target": 'quantityAdjustment', |
| 1 | +<%= turbo_frame_tag :resource_modal, target: "_top" do %> |
| 2 | + <%= render component("ui/modal").new(title: t(".title")) do |modal| %> |
| 3 | + <%= form_for @stock_item, url: form_url, html: { id: form_id } do |f| %> |
| 4 | + <div |
| 5 | + class="flex flex-col gap-6 pb-4" |
| 6 | + data-controller="<%= stimulus_id %>" |
| 7 | + data-<%= stimulus_id %>-initial-count-on-hand-value="<%= @stock_item.count_on_hand_was || @stock_item.count_on_hand %>" |
| 8 | + data-action="input-><%= stimulus_id %>#updateCountOnHand" |
| 9 | + > |
| 10 | + <div class="flex gap-4"> |
| 11 | + <%= link_to spree.edit_admin_product_variant_path( |
| 12 | + @stock_item.variant.product, |
| 13 | + @stock_item.variant, |
| 14 | + ), |
| 15 | + data: {turbo_frame: "_top"}, |
| 16 | + class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %> |
| 17 | + <%= render component("ui/resource_item").new( |
| 18 | + thumbnail: |
| 19 | + ( |
| 20 | + @stock_item.variant.images.first || |
| 21 | + @stock_item.variant.product.gallery.images.first |
| 22 | + )&.url(:small), |
| 23 | + title: @stock_item.variant.name, |
| 24 | + subtitle: |
| 25 | + "#{@stock_item.variant.sku}#{@stock_item.variant.options_text.presence&.prepend(" - ")}", |
| 26 | + ) %> |
| 27 | + <% end %> |
| 28 | + <%= link_to spree.edit_admin_stock_location_path(@stock_item.stock_location), |
| 29 | + data: {turbo_frame: "_top"}, |
| 30 | + class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %> |
| 31 | + <%= render component("ui/resource_item").new( |
| 32 | + title: @stock_item.stock_location.name, |
| 33 | + subtitle: "#{Spree::StockLocation.model_name.human} #{@stock_item.stock_location.code}", |
51 | 34 | ) %> |
52 | 35 | <% end %> |
53 | | - |
54 | | - <%= render component("ui/forms/switch_field").new( |
55 | | - name: "#{f.object_name}[backorderable]", |
56 | | - label: Spree::StockItem.human_attribute_name(:backorderable), |
57 | | - error: f.object.errors[:backorderable], |
58 | | - hint: t(".backorderable_hint_html"), |
59 | | - checked: f.object.backorderable?, |
60 | | - include_hidden: true, |
61 | | - ) %> |
62 | 36 | </div> |
63 | | - <% end %> |
64 | 37 |
|
65 | | - <% modal.with_actions do %> |
66 | | - <form method="dialog"> |
67 | | - <%= render component("ui/button").new( |
68 | | - scheme: :secondary, |
69 | | - text: t(".cancel"), |
| 38 | + <%= render component("ui/forms/field").text_field( |
| 39 | + f, |
| 40 | + :count_on_hand, |
| 41 | + readonly: true, |
| 42 | + value: @stock_item.count_on_hand_was || @stock_item.count_on_hand, |
| 43 | + "data-#{stimulus_id}-target": 'countOnHand', |
| 44 | + ) %> |
| 45 | + <%= render component("ui/forms/field").new( |
| 46 | + label: t(".quantity_adjustment"), |
| 47 | + hint: t(".quantity_adjustment_hint_html"), |
| 48 | + ) do %> |
| 49 | + <%= render component("ui/forms/input").new( |
| 50 | + value: params[:quantity_adjustment] || 0, |
| 51 | + name: :quantity_adjustment, |
| 52 | + type: :number, |
| 53 | + step: 1, |
| 54 | + "data-#{stimulus_id}-target": 'quantityAdjustment', |
70 | 55 | ) %> |
71 | | - </form> |
| 56 | + <% end %> |
| 57 | + |
| 58 | + <%= render component("ui/forms/switch_field").new( |
| 59 | + name: "#{f.object_name}[backorderable]", |
| 60 | + label: Spree::StockItem.human_attribute_name(:backorderable), |
| 61 | + error: f.object.errors[:backorderable], |
| 62 | + hint: t(".backorderable_hint_html"), |
| 63 | + checked: f.object.backorderable?, |
| 64 | + include_hidden: true, |
| 65 | + ) %> |
| 66 | + </div> |
| 67 | + <% end %> |
72 | 68 |
|
| 69 | + <% modal.with_actions do %> |
| 70 | + <form method="dialog"> |
73 | 71 | <%= render component("ui/button").new( |
74 | | - tag: :button, |
75 | | - text: t(".submit"), |
76 | | - form: form_id, |
| 72 | + scheme: :secondary, |
| 73 | + text: t(".cancel"), |
77 | 74 | ) %> |
78 | | - <% end %> |
| 75 | + </form> |
| 76 | + |
| 77 | + <%= render component("ui/button").new( |
| 78 | + tag: :button, |
| 79 | + text: t(".submit"), |
| 80 | + form: form_id, |
| 81 | + ) %> |
79 | 82 | <% end %> |
80 | 83 | <% end %> |
81 | | - |
82 | | - <%= render component("stock_items/index").new(page: @page) %> |
83 | | -</div> |
| 84 | +<% end %> |
0 commit comments