Commit 4d27b784c039b4304510b8cedc423283056c8701

Authored by Fellipe Souto Sampaio
Committed by Rafael Manzo
1 parent 3af54fad

Range's new feature has reading listing now

Pending select action to choose reading
Pending unit and acceptance test
app/controllers/mezuro_ranges.rb
... ... @@ -1,4 +0,0 @@
1   -include OwnershipAuthentication
2   -
3   -class MezuroRangesController < ApplicationController
4   -end
5 0 \ No newline at end of file
app/controllers/mezuro_ranges_controller.rb
... ... @@ -6,6 +6,8 @@ class MezuroRangesController &lt; ApplicationController
6 6 @mezuro_range = MezuroRange.new
7 7 @mezuro_range.metric_configuration_id = params[:metric_configuration_id].to_i
8 8 @mezuro_range.mezuro_configuration_id = params[:mezuro_configuration_id].to_i
  9 + @reading_group_id = MetricConfiguration.find(@mezuro_range.metric_configuration_id).reading_group_id
  10 + @reading_group = ReadingGroup.find(@reading_group_id)
9 11 end
10 12  
11 13 def show
... ... @@ -26,5 +28,4 @@ class MezuroRangesController &lt; ApplicationController
26 28 def edit
27 29 end
28 30  
29   -
30 31 end
31 32 \ No newline at end of file
... ...
app/views/mezuro_ranges/_form.html.erb
1 1 <%= render :partial => 'shared/form_errors', :locals => {:object => @mezuro_range} %>
2   -
  2 +
3 3 <div class="form-group">
4 4 <%= f.label :beginning, class: 'control-label' %><br>
5 5 <%= f.text_field :beginning, class: 'form-control' %>
... ... @@ -7,7 +7,7 @@
7 7  
8 8 <div class="form-group">
9 9 <%= f.label :end, class: 'control-label' %><br>
10   - <%= f.text_area :end, class: 'form-control' %>
  10 + <%= f.text_field :end, class: 'form-control' %>
11 11 </div>
12 12  
13 13 <div class="form-group">
... ...
app/views/mezuro_ranges/_no_readings.html.erb 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +<tr>
  2 + <% col_number = reading_groups_owner?(@reading_group.id) ? 5 : 3 %>
  3 + <td colspan="<%= col_number %>">There are no readings yet!</td>
  4 +</tr>
... ...
app/views/mezuro_ranges/_reading.html.erb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +<tr>
  2 + <td><%= reading.label %></td>
  3 + <td><%= reading.grade %></td>
  4 + <td style="background-color: #<%= reading.color %>; width: 20%;">&nbsp;</td>
  5 +</tr>
0 6 \ No newline at end of file
... ...
app/views/mezuro_ranges/new.html.erb
1 1 <h1>New Range</h1>
2 2  
3   -
4 3 <%= form_for(@mezuro_range, :url => mezuro_configuration_metric_configuration_path(@mezuro_range.mezuro_configuration_id,
5 4 @mezuro_range.metric_configuration_id)) do |f| %>
6 5 <%= render partial: 'form', locals: {f: f} %>
7 6 <% end %>
  7 +
  8 +<table class="table table-hover">
  9 + <thead>
  10 + <tr>
  11 + <th>Label</th>
  12 + <th>Grade</th>
  13 + <th>Color</th>
  14 + </tr>
  15 + </thead>
  16 +
  17 + <tbody>
  18 + <% if @reading_group.readings.size == 0 %>
  19 + <%= render partial: 'no_readings' %>
  20 + <% else %>
  21 + <%= render partial: 'reading', collection: @reading_group.readings, as: :reading %>
  22 + <% end %>
  23 + </tbody>
  24 +
  25 +</table>
... ...