1
0

Added action links to readouts view

This commit is contained in:
cryptogopher 2019-12-21 18:25:02 +01:00
parent b6dbf369d1
commit df15ae746c
4 changed files with 23 additions and 32 deletions

View File

@ -1,7 +1,8 @@
module MeasurementsHelper
def format_datetime(m)
m.taken_at.getlocal
.strftime("%F <small>%R&emsp;(#{time_ago_in_words(m.taken_at)} ago)</small>").html_safe
.strftime("%F <small>%R&emsp;(~#{time_ago_in_words(m.taken_at)} ago)</small>")
.html_safe
end
def format_time(m)
@ -40,4 +41,12 @@ module MeasurementsHelper
[s.name, s.id]
end
end
def action_links(m)
link_to(l(:button_retake), retake_measurement_path(m),
{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: {}})
end
end

View File

@ -23,15 +23,7 @@
</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"
} %>
<%= link_to l(:button_edit), edit_measurement_path(m), {
remote: true,
class: "icon icon-edit"
} %>
<%= delete_link measurement_path(m), {remote: true, data: {}} %>
<%= action_links(m) %>
</td>
</tr>
<% end %>

View File

@ -8,28 +8,10 @@
<table>
<tr>
<td style="width:100%"></td>
<td>
<%= select_tag 'quantity_id', toggle_column_options %>
</td>
<td>
<%= submit_tag l(:button_add) %>
</td>
<td><%= select_tag 'quantity_id', toggle_column_options %></td>
<td><%= submit_tag l(:button_add) %></td>
</tr>
</table>
<% end %>
</div>
</fieldset>
<table class="list" style="border:none; width:100%">
<tr>
<% total_width = 3 + @quantities.length %>
<td style="visibility: hidden; border: none; width:<%= 3 * 100/total_width%>%"></td>
<% @quantities.each do |q| %>
<td class="action" style="width:<%= 100/total_width %>%">
<%= link_to l(:button_hide),
toggle_column_measurement_path(@measurement, quantity_id: q.id),
{class: "icon icon-close", method: :post, remote: true} %>
</td>
<% end %>
</tr>
</table>

View File

@ -5,10 +5,16 @@
<thead>
<tr>
<% total_width = 3 + @quantities.length %>
<th style="width:<%= 3 * 100/total_width%>%"><%= l(:field_taken_at_date) %></th>
<th style="width:<%= 2 * 100/total_width%>%"><%= l(:field_taken_at_date) %></th>
<% @quantities.each do |q| %>
<th style="width:<%= 100/total_width %>%"><%= q.name %></th>
<th style="width:<%= 100/total_width %>%"><%= q.name %>
<div style="float:right;">
<%= link_to '', toggle_column_measurement_path(@measurement, quantity_id: q.id),
{class: "icon icon-close", method: :post, remote: true} %>
</div>
</th>
<% end %>
<th style="width:<%= 100/total_width %>%"><%= l(:field_action) %></th>
</tr>
</thead>
<tbody>
@ -21,6 +27,7 @@
<% @requested_r[index].each do |*, value| %>
<td class="primary value"><%= format_value(value) %></td>
<% end %>
<td class="action"><%= action_links(m) %></td>
</tr>
<tr class="<%= row_class %>" style="display:none">
@ -38,6 +45,7 @@
<p class="value"><%= format_value(value) %></p>
</td>
<% end %>
<td rowspan="<%= rows %>" class="action"><%= action_links(m) %></td>
</tr>
<% next unless @quantities.length > 0 %>