mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-04-02 07:01:59 -04:00
Make the form read only if issue id closed
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<% @issue.line_items.build if @issue.line_items.empty? %>
|
||||
<% readonly = @issue.status.is_closed? %>
|
||||
|
||||
<div class="box tabular" data-nested-form data-wrapper-selector=".line-item">
|
||||
<% @issue.line_items.build if @issue.line_items.empty? && !readonly %>
|
||||
|
||||
<div class="box tabular" <%= 'data-nested-form data-wrapper-selector=".line-item"' unless readonly %>>
|
||||
<p><strong>Line Items</strong></p>
|
||||
|
||||
<table class="list line-items-table">
|
||||
@@ -9,26 +11,30 @@
|
||||
<th>Description</th>
|
||||
<th style="width:120px;">Quantity</th>
|
||||
<th style="width:150px;">Unit Price</th>
|
||||
<th style="width:80px;"></th>
|
||||
<% unless readonly %>
|
||||
<th style="width:80px;"></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody data-nested-form-container>
|
||||
<tbody <%= 'data-nested-form-container' unless readonly %>>
|
||||
<%= f.fields_for :line_items do |item_form| %>
|
||||
<%= render "line_items/line_item_fields", f: item_form %>
|
||||
<%= render "line_items/line_item_fields", f: item_form, readonly: readonly %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<template data-nested-form-template>
|
||||
<%= f.fields_for :line_items, LineItem.new, child_index: "NEW_RECORD" do |item_form| %>
|
||||
<%= render "line_items/line_item_fields", f: item_form %>
|
||||
<% end %>
|
||||
</template>
|
||||
<% unless readonly %>
|
||||
<template data-nested-form-template>
|
||||
<%= 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 %>
|
||||
<% end %>
|
||||
</template>
|
||||
|
||||
<p>
|
||||
<button type="button" class="icon icon-add" data-nested-form-add>
|
||||
Add Line Item
|
||||
</button>
|
||||
</p>
|
||||
<p>
|
||||
<button type="button" class="icon icon-add" data-nested-form-add>
|
||||
Add Line Item
|
||||
</button>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -1,12 +1,13 @@
|
||||
<tr class="line-item">
|
||||
<%= f.hidden_field :id %>
|
||||
<%= f.hidden_field :_destroy %>
|
||||
<%= f.hidden_field :_destroy unless readonly %>
|
||||
|
||||
<td>
|
||||
<%= f.text_field :description,
|
||||
size: 50,
|
||||
placeholder: "Description",
|
||||
:no_label => true %>
|
||||
no_label: true,
|
||||
disabled: readonly %>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@@ -14,21 +15,25 @@
|
||||
step: 1,
|
||||
min: 1,
|
||||
style: "width:90px;",
|
||||
:no_label => true %>
|
||||
no_label: true,
|
||||
disabled: readonly %>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<%= f.number_field :unit_price,
|
||||
step: 0.01,
|
||||
style: "width:120px;",
|
||||
:no_label => true %>
|
||||
no_label: true,
|
||||
disabled: readonly %>
|
||||
</td>
|
||||
|
||||
<td style="text-align:center;">
|
||||
<button type="button"
|
||||
class="icon-only icon-del"
|
||||
title="Remove"
|
||||
data-nested-form-remove>
|
||||
</button>
|
||||
</td>
|
||||
<% unless readonly %>
|
||||
<td style="text-align:center;">
|
||||
<button type="button"
|
||||
class="icon-only icon-del"
|
||||
title="Remove"
|
||||
data-nested-form-remove>
|
||||
</button>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
Reference in New Issue
Block a user