1
0

WIP Targets #edit/#update

NestedUniqueness properly restores collection.target
This commit is contained in:
cryptogopher
2021-04-23 19:19:44 +02:00
parent 37e3b98788
commit bea0a8371d
9 changed files with 93 additions and 40 deletions

View File

@@ -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>

View File

@@ -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,

View File

@@ -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)}} %>