-
-
Notifications
You must be signed in to change notification settings - Fork 572
Expand file tree
/
Copy path_form.html.erb
More file actions
109 lines (94 loc) · 5.12 KB
/
_form.html.erb
File metadata and controls
109 lines (94 loc) · 5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<%= simple_form_for @item, remote: request.xhr?, html: {class: 'form-horizontal'} do |f| %>
<section class="content">
<div class="container-fluid">
<div class="row">
<!-- left column -->
<div class="col-md-12">
<!-- jquery validation -->
<div class="card card-primary">
<!-- /.card-header -->
<!-- form start -->
<div class="card-body">
<%= f.input :name, label: "Name", wrapper: :input_group do %>
<span class="input-group-text"><i class="fa fa-tag"></i></span>
<%= f.input_field :name, class: "form-control" %>
<% end %>
<div class='w-1/4'>
<%= f.input :item_category_id, label: 'Category', collection: @item_categories, hint: 'Categories can help organize and identify items' %>
</div>
<div class='w-1/4'>
<%= f.input :reporting_category, label: 'NDBN Reporting Category', collection: Item.reporting_categories_for_select, disabled: !!@item.kit_id, required: !@item.kit_id, hint: @reporting_category_hint %>
</div>
<%= f.input :name, label: "Value per item", wrapper: :input_group do %>
<span class="input-group-text"><i class="fa fa-money"></i></span>
<%= f.input_field :value_in_dollars, class: "form-control" %>
<% end %>
<%= f.input :name, label: "Quantity Per Individual", wrapper: :input_group do %>
<%= f.input_field :distribution_quantity, class: "form-control" %>
<% end %>
<% if current_user.has_cached_role?(Role::ORG_ADMIN, current_organization) %>
<%= f.input :name, label: "On hand minimum quantity", wrapper: :input_group do %>
<%= f.input_field :on_hand_minimum_quantity, input_html: {value: 0}, class: "form-control" %>
<% end %>
<%= f.input :name, label: "On hand recommended quantity", wrapper: :input_group do %>
<%= f.input_field :on_hand_recommended_quantity, class: "form-control" %>
<% end %>
<% end %>
<%= f.input :name, label: "Package size", wrapper: :input_group do %>
<%= f.input_field :package_size, class: "form-control", min: 0 %>
<% end %>
<%= f.input :name, label: "Request limit (individual items)", wrapper: :input_group do %>
<%= f.input_field :unit_request_limit, class: "form-control", min: 0 %>
<% end %>
<% if Flipper.enabled?(:enable_packs) && current_organization.request_units.present? %>
<%= f.input :request_units, label: "Additional Custom Request Units" do %>
<% current_organization.request_units.each do |unit| %>
<% item_unit = @item.request_units.find { |item_unit| item_unit.name == unit.name } %>
<% selected = item_unit.present? %>
<div class="form-check mb-2">
<%= check_box_tag "item[unit_ids][]", unit.id, selected, id: "unit_#{unit.id}", class: "form-check-input" %>
<%= label_tag "unit_#{unit.id}", unit.name, class: "form-check-label me-2" %>
<%= number_field_tag "item[unit_limits][#{unit.id}]",
item_unit&.request_limit,
class: "form-control d-inline-block w-auto",
min: 0,
placeholder: "limit",
disabled: !selected,
autocomplete: "off" %>
</div>
<% end %>
<%= hidden_field_tag "item[unit_ids][]", "" %>
<% end %>
<% end %>
<%= f.input :visible, label: "Item is Visible to Partners?", wrapper: :input_group do %>
<%= f.check_box :visible_to_partners, {class: "input-group-text", id: "visible_to_partners"}, "true", "false" %>
<% end %>
<%= f.label :additional_info, "Additional Information (Bank Use Only) " %> <i>(500 character max)</i>
<%= f.input :additional_info, label: false, maxlength: 500, wrapper: :input_group %>
</div>
<!-- /.card-body -->
<div class="card-footer">
<%= submit_button %>
</div>
</div>
<!-- /.card -->
</div>
<!--/.col (left) -->
<!-- right column -->
<div class="col-md-6">
</div>
<!--/.col (right) -->
</div>
<!-- /.row -->
</div><!-- /.container-fluid -->
</section>
<% end %>
<script>
document.addEventListener("change", (e) => {
if (e.target.matches('input[type="checkbox"][id^="unit_"]')) {
const id = e.target.id.replace("unit_", "");
const limit = document.querySelector(`input[name="item[unit_limits][${id}]"]`);
if (limit) limit.disabled = !e.target.checked;
}
});
</script>