Fixed remove button functionality

This commit is contained in:
2026-03-07 13:03:44 -05:00
parent 1d29d2a816
commit 894741f60f
3 changed files with 19 additions and 8 deletions

View File

@@ -2,7 +2,10 @@
<% @issue.line_items.build if @issue.line_items.empty? && !readonly %> <% @issue.line_items.build if @issue.line_items.empty? && !readonly %>
<div class="box tabular" <%= 'data-nested-form data-wrapper-selector=".line-item"' unless readonly %>> <div class="box tabular"
data-nested-form
data-wrapper-selector=".line-item">
<p><strong><%= t :label_line_items %></strong></p> <p><strong><%= t :label_line_items %></strong></p>
<table class="list line-items-table"> <table class="list line-items-table">
@@ -17,9 +20,11 @@
</tr> </tr>
</thead> </thead>
<tbody <%= 'data-nested-form-container' unless readonly %>> <tbody data-nested-form-container>
<%= f.fields_for :line_items do |item_form| %> <%= f.fields_for :line_items do |item_form| %>
<%= render "line_items/line_item_fields", f: item_form, readonly: readonly %> <%= render "line_items/line_item_fields",
f: item_form,
readonly: readonly %>
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
@@ -27,14 +32,19 @@
<% unless readonly %> <% unless readonly %>
<template data-nested-form-template> <template data-nested-form-template>
<%= f.fields_for :line_items, LineItem.new, child_index: "NEW_RECORD" do |item_form| %> <%= f.fields_for :line_items, LineItem.new, child_index: "NEW_RECORD" do |item_form| %>
<%= render "line_items/line_item_fields", f: item_form, readonly: false %> <%= render "line_items/line_item_fields",
f: item_form,
readonly: false %>
<% end %> <% end %>
</template> </template>
<p> <p>
<button type="button" class="icon icon-add" data-nested-form-add> <button type="button"
Add Line Item class="icon icon-add"
data-nested-form-add>
<%= l(:button_add) %>
</button> </button>
</p> </p>
<% end %> <% end %>
</div> </div>

View File

@@ -1,6 +1,6 @@
<tr class="line-item"> <tr class="line-item">
<%= f.hidden_field :id %> <%= f.hidden_field :id %>
<%= f.hidden_field :_destroy unless readonly %> <%= f.hidden_field :_destroy %>
<td> <td>
<%= f.text_field :description, <%= f.text_field :description,
@@ -31,7 +31,7 @@
<td style="text-align:center;"> <td style="text-align:center;">
<button type="button" <button type="button"
class="icon-only icon-del" class="icon-only icon-del"
title="Remove" title="<%=l(:label_remove)%>"
data-nested-form-remove> data-nested-form-remove>
</button> </button>
</td> </td>

View File

@@ -16,5 +16,6 @@ en:
label_line_items: "Line Items" label_line_items: "Line Items"
label_price: "Unit Price" label_price: "Unit Price"
label_qty: "Quantity" label_qty: "Quantity"
label_remove: "Remove"
label_total: "Total" label_total: "Total"