1
0

Preliminary Measurement edit/update

This commit is contained in:
cryptogopher
2019-12-01 20:02:45 +01:00
parent 54040a2764
commit 7cb3ac4134
5 changed files with 55 additions and 16 deletions

View File

@@ -2,8 +2,8 @@
<table class="list">
<thead>
<tr>
<th><%= l(:field_name) %></th>
<th><%= l(:field_taken_at_date) %></th>
<th><%= l(:field_name) %></th>
<th><%= l(:field_source) %></th>
<th style="width:10%"><%= l(:field_action) %></th>
</tr>
@@ -12,17 +12,45 @@
<% @measurements.each do |m| %>
<% next if m.new_record? %>
<tr id="measurement-<%= m.id %>" class="measurement <%= 'hidden' if m.hidden %>">
<td class="name"><%= m.name %></td>
<td class="date"><%= m.taken_at.strftime("%F %R") %></td>
<td class="name"><%= m.name %></td>
<td class="source"><%= m.source.name if m.source.present? %></td>
<td class="action">
<%= link_to l(:button_retake), retake_measurement_path(m), {
remote: true,
class: "icon icon-reload"
} %>
remote: true,
class: "icon icon-reload"
} %>
<%= link_to l(:button_edit), edit_measurement_path(m), {
remote: true,
class: "icon icon-edit"
} %>
<%= delete_link measurement_path(m), {remote: true, data: {}} %>
</td>
</tr>
<% next unless (m == @measurement) &&
((action_name == "edit") ||
(action_name == "update" && @measurement.errors.present?)) %>
<tr>
<td class="form" colspan="4">
<div id="edit-measurement">
<%= labelled_form_for @measurement,
url: measurement_path(@measurement),
method: :patch, remote: true,
html: {id: 'measurement-edit-form', name: 'measurement-edit-form'} do |f| %>
<%= render partial: 'measurements/form', locals: {f: f} %>
<div class="tabular">
<p>
<%= submit_tag l(:button_save) %>
<%= link_to l(:button_cancel), "#",
onclick: '$(this).closest("tr").remove(); return false;' %>
</p>
</div>
<% end %>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -50,18 +50,16 @@
<td class="description"><%= q.description %></td>
<td class="formula"><%= checked_image q.formula.present? %></td>
<td class="action">
<%=
link_to l(:button_edit), edit_quantity_path(q), {
remote: true,
class: "icon icon-edit"
}
%>
<%= link_to l(:button_edit), edit_quantity_path(q), {
remote: true,
class: "icon icon-edit"
} %>
<%= delete_link quantity_path(q), {remote: true, data: {}} %>
</td>
</tr>
<% next unless (q == @quantity) &&
((action_name == "edit") || (action_name == "update" && @quantity.errors.present?))
%>
((action_name == "edit") ||
(action_name == "update" && @quantity.errors.present?)) %>
<tr>
<td class="form" colspan="6">
<div id="edit-quantity">