Added action links to readouts view
This commit is contained in:
parent
b6dbf369d1
commit
df15ae746c
@ -1,7 +1,8 @@
|
|||||||
module MeasurementsHelper
|
module MeasurementsHelper
|
||||||
def format_datetime(m)
|
def format_datetime(m)
|
||||||
m.taken_at.getlocal
|
m.taken_at.getlocal
|
||||||
.strftime("%F <small>%R (#{time_ago_in_words(m.taken_at)} ago)</small>").html_safe
|
.strftime("%F <small>%R (~#{time_ago_in_words(m.taken_at)} ago)</small>")
|
||||||
|
.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_time(m)
|
def format_time(m)
|
||||||
@ -40,4 +41,12 @@ module MeasurementsHelper
|
|||||||
[s.name, s.id]
|
[s.name, s.id]
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
@ -23,15 +23,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="source"><%= m.source.name if m.source.present? %></td>
|
<td class="source"><%= m.source.name if m.source.present? %></td>
|
||||||
<td class="action">
|
<td class="action">
|
||||||
<%= link_to l(:button_retake), retake_measurement_path(m), {
|
<%= action_links(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: {}} %>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -8,28 +8,10 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:100%"></td>
|
<td style="width:100%"></td>
|
||||||
<td>
|
<td><%= select_tag 'quantity_id', toggle_column_options %></td>
|
||||||
<%= select_tag 'quantity_id', toggle_column_options %>
|
<td><%= submit_tag l(:button_add) %></td>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= submit_tag l(:button_add) %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</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>
|
|
||||||
|
@ -5,10 +5,16 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% total_width = 3 + @quantities.length %>
|
<% 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| %>
|
<% @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 %>
|
<% end %>
|
||||||
|
<th style="width:<%= 100/total_width %>%"><%= l(:field_action) %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -21,6 +27,7 @@
|
|||||||
<% @requested_r[index].each do |*, value| %>
|
<% @requested_r[index].each do |*, value| %>
|
||||||
<td class="primary value"><%= format_value(value) %></td>
|
<td class="primary value"><%= format_value(value) %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<td class="action"><%= action_links(m) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="<%= row_class %>" style="display:none">
|
<tr class="<%= row_class %>" style="display:none">
|
||||||
@ -38,6 +45,7 @@
|
|||||||
<p class="value"><%= format_value(value) %></p>
|
<p class="value"><%= format_value(value) %></p>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<td rowspan="<%= rows %>" class="action"><%= action_links(m) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% next unless @quantities.length > 0 %>
|
<% next unless @quantities.length > 0 %>
|
||||||
|
Reference in New Issue
Block a user