Commit 3af54fad3728dfb7a6643077e6910ba804448edf
Committed by
Rafael Manzo
1 parent
db99ef65
Exists in
colab
and in
4 other branches
Started new feature for mezuro range
Pending listing readings Pending unit and acceptance test signed-off-by: Renan Fichberg <rfichberg@gmail.com>
Showing
6 changed files
with
74 additions
and
15 deletions
Show diff stats
app/controllers/metric_configurations_controller.rb
| ... | ... | @@ -31,6 +31,7 @@ class MetricConfigurationsController < ApplicationController |
| 31 | 31 | |
| 32 | 32 | def show |
| 33 | 33 | @reading_group = ReadingGroup.find(@metric_configuration.reading_group_id) |
| 34 | + @metric_configuration.configuration_id = params[:mezuro_configuration_id].to_i | |
| 34 | 35 | end |
| 35 | 36 | |
| 36 | 37 | def edit | ... | ... |
app/controllers/mezuro_ranges_controller.rb
| ... | ... | @@ -2,25 +2,29 @@ include OwnershipAuthentication |
| 2 | 2 | |
| 3 | 3 | class MezuroRangesController < ApplicationController |
| 4 | 4 | |
| 5 | -def show | |
| 6 | -end | |
| 5 | + def new | |
| 6 | + @mezuro_range = MezuroRange.new | |
| 7 | + @mezuro_range.metric_configuration_id = params[:metric_configuration_id].to_i | |
| 8 | + @mezuro_range.mezuro_configuration_id = params[:mezuro_configuration_id].to_i | |
| 9 | + end | |
| 7 | 10 | |
| 8 | -def create | |
| 9 | -end | |
| 11 | + def show | |
| 12 | + end | |
| 10 | 13 | |
| 11 | -def destroy | |
| 12 | -end | |
| 14 | + def create | |
| 15 | + end | |
| 13 | 16 | |
| 14 | -def update | |
| 15 | -end | |
| 17 | + def destroy | |
| 18 | + end | |
| 16 | 19 | |
| 17 | -def index | |
| 18 | -end | |
| 20 | + def update | |
| 21 | + end | |
| 19 | 22 | |
| 20 | -def edit | |
| 21 | -end | |
| 23 | + def index | |
| 24 | + end | |
| 25 | + | |
| 26 | + def edit | |
| 27 | + end | |
| 22 | 28 | |
| 23 | -def new | |
| 24 | -end | |
| 25 | 29 | |
| 26 | 30 | end |
| 27 | 31 | \ No newline at end of file | ... | ... |
app/models/mezuro_range.rb
| ... | ... | @@ -3,7 +3,7 @@ require "validators/beginning_uniqueness_validator.rb" |
| 3 | 3 | class MezuroRange < KalibroGem::Entities::Range |
| 4 | 4 | include KalibroRecord |
| 5 | 5 | |
| 6 | - attr_accessor :beginning, :end, :reading_id, :metric_configuration_id | |
| 6 | + attr_accessor :beginning, :end, :reading_id, :metric_configuration_id, :mezuro_configuration_id, :comments | |
| 7 | 7 | |
| 8 | 8 | validates :beginning, presence: true, beginning_uniqueness: true |
| 9 | 9 | validates :end, presence: true #TODO: Validates numeracy | ... | ... |
app/views/metric_configurations/show.html.erb
| ... | ... | @@ -49,7 +49,33 @@ |
| 49 | 49 | <hr> |
| 50 | 50 | |
| 51 | 51 | <h2> Ranges </h2> |
| 52 | +<% if mezuro_configuration_owner? @metric_configuration.configuration_id %> | |
| 53 | + <%= link_to 'Add Range', mezuro_configuration_metric_configuration_new_mezuro_range_path(@metric_configuration.configuration_id, | |
| 54 | + @metric_configuration.id), class: 'btn btn-info' %> | |
| 55 | +<% end %> | |
| 52 | 56 | |
| 57 | +<table class="table table-hover"> | |
| 58 | + <thead> | |
| 59 | + <tr> | |
| 60 | + <th>Label</th> | |
| 61 | + <th>Beginning</th> | |
| 62 | + <th>End</th> | |
| 63 | + </tr> | |
| 64 | + </thead> | |
| 65 | + <tbody> | |
| 66 | + | |
| 67 | + </tbody> | |
| 68 | +</table> | |
| 53 | 69 | |
| 70 | +<hr> | |
| 71 | + | |
| 72 | +<p> | |
| 73 | + <%= link_to 'Back', mezuro_configuration_path(@metric_configuration.configuration_id), class: 'btn btn-default' %> | |
| 74 | +<% if mezuro_configuration_owner? @metric_configuration.configuration_id %> | |
| 75 | + <%= link_to 'Destroy Metric Configuration', mezuro_configuration_metric_configuration_path(@metric_configuration.configuration_id, | |
| 76 | + @metric_configuration.id), method: :delete, data: { confirm: 'Are you sure that you want to destroy this metric configuration?' }, | |
| 77 | + class: 'btn btn-danger' %> | |
| 78 | + <% end %> | |
| 79 | +</p> | |
| 54 | 80 | |
| 55 | 81 | ... | ... |
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | + <%= render :partial => 'shared/form_errors', :locals => {:object => @mezuro_range} %> | |
| 2 | + | |
| 3 | + <div class="form-group"> | |
| 4 | + <%= f.label :beginning, class: 'control-label' %><br> | |
| 5 | + <%= f.text_field :beginning, class: 'form-control' %> | |
| 6 | + </div> | |
| 7 | + | |
| 8 | + <div class="form-group"> | |
| 9 | + <%= f.label :end, class: 'control-label' %><br> | |
| 10 | + <%= f.text_area :end, class: 'form-control' %> | |
| 11 | + </div> | |
| 12 | + | |
| 13 | + <div class="form-group"> | |
| 14 | + <%= f.label :comments, class: 'control-label' %><br> | |
| 15 | + <%= f.text_area :comments, class: 'form-control' %> | |
| 16 | + </div> | |
| 17 | + | |
| 18 | + <%= f.submit 'Save', class: 'btn btn-primary' %> | |
| 19 | + | |
| 20 | + <%= link_to 'Back', mezuro_configuration_metric_configuration_path(@mezuro_range.mezuro_configuration_id, @mezuro_range.metric_configuration_id), | |
| 21 | + class: 'btn btn-default' %> | ... | ... |
| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | +<h1>New Range</h1> | |
| 2 | + | |
| 3 | + | |
| 4 | +<%= form_for(@mezuro_range, :url => mezuro_configuration_metric_configuration_path(@mezuro_range.mezuro_configuration_id, | |
| 5 | + @mezuro_range.metric_configuration_id)) do |f| %> | |
| 6 | + <%= render partial: 'form', locals: {f: f} %> | |
| 7 | +<% end %> | ... | ... |