1
0
This repository has been archived on 2023-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
body_tracking/app/views/quantities/_index.html.erb
2019-11-28 21:00:14 +01:00

94 lines
3.3 KiB
Plaintext

<%= render partial: 'quantities/filters',
locals: {url: filter_project_quantities_path(@project)} %>
<% if @quantities.any? { |q| q.persisted? } %>
<table class="list">
<thead>
<tr>
<th><%= l(:field_name) %></th>
<th><%= l(:field_order) %></th>
<th><%= l(:field_domain) %></th>
<th><%= l(:field_description) %></th>
<th><%= l(:field_formula) %></th>
<th><%= l(:field_action) %></th>
</tr>
</thead>
<tbody>
<% Quantity.each_with_level(@quantities) do |q, level| %>
<%
next if q.new_record?
quantity_class = "quantity"
quantity_class += " project idnt idnt-#{level+1}"
quantity_class += " primary" if q.primary
%>
<tr id="quantity-<%= q.id %>" class="<%= quantity_class %>">
<td class="name">
<%= link_to '', toggle_quantity_path(q), {
remote: true,
method: :post,
class: "icon #{q.primary ? "icon-fav" : "icon-fav-off"}"
}
%>
<%= q.name %>
</td>
<td class="order">
<% [:up, :down, :left, :right].each do |direction| %>
<%=
if q.movable?(direction)
link_to '', move_quantity_path(q, direction), {
remote: true,
method: :post,
class: "icon icon-move icon-move-#{direction}",
style: (action_name == "edit") ? "visibility: hidden;" : ""
}
else
link_to '', '', {class: "icon", style: "visibility: hidden;"}
end
%>
<% end %>
</td>
<td class="domain"><%= q.domain %></td>
<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",
style: (action_name == "edit") ? "visibility: hidden;" : ""
}
%>
<%= delete_link quantity_path(q), {remote: true, data: {}} %>
</td>
</tr>
<% next unless (q == @quantity) &&
((action_name == "edit") || (action_name == "update" && @quantity.errors.present?))
%>
<tr>
<td class="form" colspan="6">
<div id="edit-quantity">
<%= labelled_form_for @quantity,
url: quantity_path(@quantity),
method: :patch, remote: true,
html: {id: 'quantity-edit-form', name: 'quantity-edit-form'} do |f| %>
<%= render partial: 'quantities/form', locals: {f: f} %>
<%= submit_tag l(:button_save) %>
<%=
link_to l(:button_cancel), "#",
onclick: '$(this).closest("tr").remove();
$("#quantities a.icon-edit").css("visibility", "visible");
$("#quantities a.icon-move").css("visibility", "visible");
return false;'
%>
<% end %>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>