WIP Targets #edit/#update
NestedUniqueness properly restores collection.target
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<%= labelled_form_for @targets,
|
||||
url: project_targets_path(@project, @view_params),
|
||||
method: :patch, remote: true,
|
||||
html: {id: 'edit-target-form', name: 'edit-target-form'} do |f| %>
|
||||
<%= labelled_form_for @goal, url: goal_targets_path(@goal), method: :patch, remote: true,
|
||||
html: {id: 'edit-target-form', name: 'edit-target-form'} do |goal_f| %>
|
||||
|
||||
<%= render partial: 'targets/form', locals: {f: f} %>
|
||||
<div class="box tabular">
|
||||
<%= render partial: 'targets/form', locals: {goal_f: goal_f} %>
|
||||
</div>
|
||||
|
||||
<div class="tabular">
|
||||
<p>
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= goal_f.fields_for :targets, @targets, child_index: '' do |target_f| %>
|
||||
<%= goal_f.fields_for :targets, @targets, index: '', child_index: '' do |target_f| %>
|
||||
<%= error_messages_for target_f.object %>
|
||||
|
||||
<p class="target">
|
||||
<%= target_f.hidden_field :id %>
|
||||
<%= target_f.hidden_field :_destroy %>
|
||||
<em class="info"><%= t ".choose_quantity" %></em>
|
||||
<%= target_f.select :quantity_id, quantity_options,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% target_f.object.thresholds.new unless last_quantity.leaf? %>
|
||||
<%= target_f.fields_for :thresholds, child_index: '' do |threshold_f| %>
|
||||
<%= target_f.fields_for :thresholds, index: '', child_index: '' do |threshold_f| %>
|
||||
<% threshold_q = threshold_f.object.quantity %>
|
||||
<% parent_id = threshold_q.nil? ? last_quantity.id : threshold_q.parent_id %>
|
||||
<%= threshold_f.collection_select :quantity_id,
|
||||
@@ -16,6 +16,7 @@
|
||||
}
|
||||
});
|
||||
return false;"} %>
|
||||
<%# TODO: update above ajax with -1/no change/+1 logic based on copying existing threshold and proper ID/destroy handling %>
|
||||
<%# {autocomplete: 'off',
|
||||
data: {remote: true, url: subthresholds_project_targets_path(parent_id: parent_id)}} %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user