Initial line item idea

This commit is contained in:
2026-03-01 15:04:25 -05:00
parent b95a3b6623
commit eb6beea5fa
12 changed files with 2716 additions and 28 deletions

View File

@@ -7,3 +7,6 @@
<p>
<%= select_estimate %>
</p>
<%= render "line_items/issue_form" %>

View File

@@ -0,0 +1,13 @@
<div class="line-item">
<%= f.hidden_field :id %>
<%= f.text_field :description, placeholder: "Description" %>
<%= f.number_field :quantity, step: 1 ,placeholder: "Quantity"%>
<%= f.number_field :unit_price, step: 0.01, placeholder: "Unit Price" %>
<%= f.hidden_field :_destroy %>
<button type="button" data-action="nested-form#remove">
Remove
</button>
</div>

View File

@@ -0,0 +1,31 @@
<%= form_with model: @issue do |f| %>
<!-- Existing issue fields -->
<h3>Invoice Line Items</h3>
<div
data-controller="nested-form"
data-nested-form-wrapper-selector-value=".line-item"
>
<div data-nested-form-target="container">
<%= f.fields_for :invoice_line_items do |item_form| %>
<%= render "line_items/invoice_line_item_fields", f: item_form %>
<% end %>
</div>
<template data-nested-form-target="template">
<%= f.fields_for :invoice_line_items,
LineItem.new,
child_index: "NEW_RECORD" do |item_form| %>
<%= render "line_items/invoice_line_item_fields", f: item_form %>
<% end %>
</template>
<button type="button" data-action="nested-form#add">
Add Line Item
</button>
</div>
<%= f.submit %>
<% end %>