|
| 1 | +<div class="<%= stimulus_id %>" data-controller="<%= stimulus_id %>"> |
| 2 | + <%= render component("orders/show").new(order: @order) %> |
| 3 | + <%= render component("ui/modal").new(title: t(".title", number: @shipment.number), close_path: close_path) do |modal| %> |
| 4 | + <table class="table-auto w-full"> |
| 5 | + <thead> |
| 6 | + <tr> |
| 7 | + <th class="py-2 px-4 h-10 bg-gray-15 w-16"> |
| 8 | + <%= |
| 9 | + render component("ui/forms/checkbox").new( |
| 10 | + form: form_id, |
| 11 | + "data-action": "#{stimulus_id}#selectAllRows", |
| 12 | + "data-#{stimulus_id}-target": "headerCheckbox", |
| 13 | + "aria-label": t('.select_all'), |
| 14 | + ) |
| 15 | + %> |
| 16 | + </th> |
| 17 | + <th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none"> |
| 18 | + <%= t(".product") %> |
| 19 | + </th> |
| 20 | + <th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none w-16"> |
| 21 | + <%= t(".quantity") %> |
| 22 | + </th> |
| 23 | + <th class="text-left body-small-bold text-gray-800 bg-gray-15 px-6 py-3 leading-none w-16 whitespace-nowrap"> |
| 24 | + <%= t(".total") %> |
| 25 | + </th> |
| 26 | + </tr> |
| 27 | + </thead> |
| 28 | + <tbody> |
| 29 | + <% manifest.each do |item| %> |
| 30 | + <tr class="border-gray-100 border-t"> |
| 31 | + <td class="py-2 px-4"> |
| 32 | + <%= |
| 33 | + render component("ui/forms/checkbox").new( |
| 34 | + name: "selected_variants[]", |
| 35 | + form: form_id, |
| 36 | + value: item.variant.id, |
| 37 | + "data-#{stimulus_id}-target": "checkbox", |
| 38 | + ) |
| 39 | + %> |
| 40 | + </td> |
| 41 | + |
| 42 | + <td class="px-6 py-4"> |
| 43 | + <div class="flex gap-2 grow"> |
| 44 | + <% variant = item.variant %> |
| 45 | + <%= render component("ui/thumbnail").new( |
| 46 | + src: (variant.images.first || variant.product.gallery.images.first)&.url(:small), |
| 47 | + alt: variant.name |
| 48 | + ) %> |
| 49 | + <div class="flex-col"> |
| 50 | + <div class="leading-5 text-black body-small-bold"><%= variant.name %></div> |
| 51 | + <div class="leading-5 text-gray-500 body-small"> |
| 52 | + SKU: <%= variant.sku %> |
| 53 | + <%= variant.options_text.presence&.prepend("- ") %> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + </td> |
| 58 | + <td class="px-6 py-4"> |
| 59 | + <span class="text-gray-500 body-small whitespace-nowrap"> |
| 60 | + <%= render component("ui/forms/input").new( |
| 61 | + value: item.line_item.quantity, |
| 62 | + form: form_id, |
| 63 | + name: "variants[#{item.variant.id}][quantity]", |
| 64 | + type: :number, |
| 65 | + step: 1, |
| 66 | + min: "1", |
| 67 | + max: item.line_item.quantity, |
| 68 | + "data-#{stimulus_id}-target": "quantity", |
| 69 | + "data-action": "focus->#{stimulus_id}#selectRow", |
| 70 | + ) %> |
| 71 | + </span> |
| 72 | + </td> |
| 73 | + <td class="px-6 py-4"> |
| 74 | + <span class="text-gray-500 body-small"><%= item.line_item.display_amount %></span> |
| 75 | + </td> |
| 76 | + </tr> |
| 77 | + <% end %> |
| 78 | + </tbody> |
| 79 | + </table> |
| 80 | + |
| 81 | + <% modal.with_actions do %> |
| 82 | + <%= form_tag '', id: form_id, "data-action": "submit->#{stimulus_id}#submit" %> |
| 83 | + <%= render component("ui/button").new(tag: :a, scheme: :secondary, href: close_path, type: :submit, text: t('.cancel')) %> |
| 84 | + <%= render_split_action_button %> |
| 85 | + <% end %> |
| 86 | + <% end %> |
| 87 | +</div> |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | +<form action="/your_action" method="post"> |
| 92 | + <input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>"> |
| 93 | + <input type="text" name="variants[1][quantity]" value="12"> |
| 94 | + <input type="text" name="variants[2][quantity]" value="3"> |
| 95 | + <input type="submit" value="Submit"> |
| 96 | +</form> |
0 commit comments