Targets form allows only targets within one Goal
This commit is contained in:
parent
cf0e14d87d
commit
7e8508f9d4
@ -1,53 +1,51 @@
|
|||||||
<%= error_messages_for *@targets %>
|
<%= error_messages_for *@targets %>
|
||||||
|
|
||||||
<% @targets.group_by(&:goal).each do |goal, targets| %>
|
<div class="box">
|
||||||
<div class="box">
|
<div id='goal-form' class="tabular">
|
||||||
<div id='goal-form' class="tabular">
|
<% if current_goal.persisted? %>
|
||||||
<% if goal.persisted? || goal.is_binding? %>
|
<p><%= render partial: 'goals/show_form', locals: {goal: current_goal} %></p>
|
||||||
<p><%= render partial: 'goals/show_form', locals: {goal: goal} %></p>
|
<p><%= f.date_field :effective_from, disabled: !current_goal.is_binding? %></p>
|
||||||
<p><%= f.date_field :effective_from, disabled: !goal.is_binding? %></p>
|
<% else %>
|
||||||
<% else %>
|
<%= render partial: 'goals/form', locals: {goal: current_goal} %>
|
||||||
<%= render partial: 'goals/form', locals: {goal: goal} %>
|
<% end %>
|
||||||
<% end %>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr style="width: 95%;">
|
<hr style="width: 95%;">
|
||||||
|
|
||||||
<div class="tabular">
|
<div class="tabular">
|
||||||
<% targets.each do |target| %>
|
<% @targets.each do |target| %>
|
||||||
<p class="target">
|
<p class="target">
|
||||||
<%= f.fields_for 'targets', target, index: '' do |target_f| %>
|
<%= f.fields_for 'targets', target, index: '' do |target_f| %>
|
||||||
<%= target_f.hidden_field :id %>
|
<%= target_f.hidden_field :id %>
|
||||||
<%= target_f.hidden_field :_destroy %>
|
<%= target_f.hidden_field :_destroy %>
|
||||||
<em class="info"><%= t ".choose_quantity" %></em>
|
<em class="info"><%= t ".choose_quantity" %></em>
|
||||||
<% target.thresholds.each_with_index do |thr, index| %>
|
<% target.thresholds.each_with_index do |thr, index| %>
|
||||||
<%= target_f.fields_for 'thresholds_attributes', thr, index: '' do |threshold_f| %>
|
<%= target_f.fields_for 'thresholds_attributes', thr, index: '' do |threshold_f| %>
|
||||||
<%= threshold_f.hidden_field :id %>
|
<%= threshold_f.hidden_field :id %>
|
||||||
<% if index == 0 %>
|
<% if index == 0 %>
|
||||||
<%= threshold_f.select :quantity_id, quantity_options,
|
<%= threshold_f.select :quantity_id, quantity_options,
|
||||||
{include_blank: true, required: true, label: :field_target},
|
{include_blank: true, required: true, label: :field_target},
|
||||||
onchange: "showQuantityPath(event);" %>
|
onchange: "showQuantityPath(event);" %>
|
||||||
<%= target_f.select :condition, condition_options, required: true,
|
<%= target_f.select :condition, condition_options, required: true,
|
||||||
label: '' %>
|
label: '' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= threshold_f.number_field :value, {size: 8, step: :any, label: ''} %>
|
<%= threshold_f.number_field :value, {size: 8, step: :any, label: ''} %>
|
||||||
<% if index == 0 %>
|
<% if index == 0 %>
|
||||||
<%= threshold_f.select :unit_id, unit_options, {label: ''} %>
|
<%= threshold_f.select :unit_id, unit_options, {label: ''} %>
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to t(".button_delete_target"), '#', class: 'icon icon-del',
|
|
||||||
onclick: "deleteTarget(); return false;" %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
<%= link_to t(".button_delete_target"), '#', class: 'icon icon-del',
|
||||||
|
onclick: "deleteTarget(); return false;" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p>
|
|
||||||
<%= link_to t(".button_new_target"), '#', class: 'icon icon-add',
|
|
||||||
onclick: 'newTarget(); return false;' %>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
<% end %>
|
||||||
|
<p>
|
||||||
|
<%= link_to t(".button_new_target"), '#', class: 'icon icon-add',
|
||||||
|
onclick: 'newTarget(); return false;' %>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
</div>
|
||||||
|
|
||||||
<%= javascript_tag do %>
|
<%= javascript_tag do %>
|
||||||
function showQuantityPath(event) {
|
function showQuantityPath(event) {
|
||||||
|
Reference in New Issue
Block a user