Commit 933ff3c46873ef90e5eb552f6d360447c1145996

Authored by Guilherme Rojas V. de Lima
Committed by Rafael Manzo
1 parent 2dae7177

Listing ranges in metric configuration show

Reading color should be displayed in other way instead of show its color in the ranges label text.

signed-off-by: Diego Araújo <diegoamc90@gmail.com>
app/controllers/metric_configurations_controller.rb
... ... @@ -32,6 +32,7 @@ class MetricConfigurationsController &lt; ApplicationController
32 32  
33 33 def show
34 34 @reading_group = ReadingGroup.find(@metric_configuration.reading_group_id)
  35 + @mezuro_ranges = @metric_configuration.mezuro_ranges
35 36 @metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i
36 37 end
37 38  
... ...
app/views/metric_configurations/_no_ranges.html.erb 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +<tr>
  2 +<!-- TODO: expand this columns when the user owns the metric configurations and can edit or delete this range -->
  3 + <td colspan="3">There are no ranges yet!</td>
  4 +</tr>
0 5 \ No newline at end of file
... ...
app/views/metric_configurations/_ranges.html.erb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +<tr>
  2 + <td style="color: #<%= mezuro_range.color %>"><%= mezuro_range.label %></td>
  3 + <td><%= mezuro_range.beginning %></td>
  4 + <td><%= mezuro_range.end %></td>
  5 +</tr>
0 6 \ No newline at end of file
... ...
app/views/metric_configurations/show.html.erb
... ... @@ -63,12 +63,14 @@
63 63 </tr>
64 64 </thead>
65 65 <tbody>
66   -
  66 + <% if @mezuro_ranges.size == 0 %>
  67 + <%= render partial: 'no_ranges' %>
  68 + <% else %>
  69 + <%= render partial: 'ranges', collection: @mezuro_ranges, as: :mezuro_range %>
  70 + <% end %>
67 71 </tbody>
68 72 </table>
69 73  
70   -<hr>
71   -
72 74 <p>
73 75 <%= link_to 'Back', mezuro_configuration_path(@metric_configuration.configuration_id), class: 'btn btn-default' %>
74 76 <% if mezuro_configuration_owner? @metric_configuration.configuration_id %>
... ...