From 4d27b784c039b4304510b8cedc423283056c8701 Mon Sep 17 00:00:00 2001 From: Fellipe Souto Sampaio Date: Tue, 11 Feb 2014 17:14:10 -0200 Subject: [PATCH] Range's new feature has reading listing now --- app/controllers/mezuro_ranges.rb | 4 ---- app/controllers/mezuro_ranges_controller.rb | 3 ++- app/views/mezuro_ranges/_form.html.erb | 4 ++-- app/views/mezuro_ranges/_no_readings.html.erb | 4 ++++ app/views/mezuro_ranges/_reading.html.erb | 5 +++++ app/views/mezuro_ranges/new.html.erb | 20 +++++++++++++++++++- 6 files changed, 32 insertions(+), 8 deletions(-) delete mode 100644 app/controllers/mezuro_ranges.rb create mode 100644 app/views/mezuro_ranges/_no_readings.html.erb create mode 100644 app/views/mezuro_ranges/_reading.html.erb diff --git a/app/controllers/mezuro_ranges.rb b/app/controllers/mezuro_ranges.rb deleted file mode 100644 index 165b183..0000000 --- a/app/controllers/mezuro_ranges.rb +++ /dev/null @@ -1,4 +0,0 @@ -include OwnershipAuthentication - -class MezuroRangesController < ApplicationController -end \ No newline at end of file diff --git a/app/controllers/mezuro_ranges_controller.rb b/app/controllers/mezuro_ranges_controller.rb index 468d891..22eeceb 100644 --- a/app/controllers/mezuro_ranges_controller.rb +++ b/app/controllers/mezuro_ranges_controller.rb @@ -6,6 +6,8 @@ class MezuroRangesController < ApplicationController @mezuro_range = MezuroRange.new @mezuro_range.metric_configuration_id = params[:metric_configuration_id].to_i @mezuro_range.mezuro_configuration_id = params[:mezuro_configuration_id].to_i + @reading_group_id = MetricConfiguration.find(@mezuro_range.metric_configuration_id).reading_group_id + @reading_group = ReadingGroup.find(@reading_group_id) end def show @@ -26,5 +28,4 @@ class MezuroRangesController < ApplicationController def edit end - end \ No newline at end of file diff --git a/app/views/mezuro_ranges/_form.html.erb b/app/views/mezuro_ranges/_form.html.erb index 30b427c..fc7b3f9 100644 --- a/app/views/mezuro_ranges/_form.html.erb +++ b/app/views/mezuro_ranges/_form.html.erb @@ -1,5 +1,5 @@ <%= render :partial => 'shared/form_errors', :locals => {:object => @mezuro_range} %> - +
<%= f.label :beginning, class: 'control-label' %>
<%= f.text_field :beginning, class: 'form-control' %> @@ -7,7 +7,7 @@
<%= f.label :end, class: 'control-label' %>
- <%= f.text_area :end, class: 'form-control' %> + <%= f.text_field :end, class: 'form-control' %>
diff --git a/app/views/mezuro_ranges/_no_readings.html.erb b/app/views/mezuro_ranges/_no_readings.html.erb new file mode 100644 index 0000000..ba3fda6 --- /dev/null +++ b/app/views/mezuro_ranges/_no_readings.html.erb @@ -0,0 +1,4 @@ + + <% col_number = reading_groups_owner?(@reading_group.id) ? 5 : 3 %> + There are no readings yet! + diff --git a/app/views/mezuro_ranges/_reading.html.erb b/app/views/mezuro_ranges/_reading.html.erb new file mode 100644 index 0000000..9bb9963 --- /dev/null +++ b/app/views/mezuro_ranges/_reading.html.erb @@ -0,0 +1,5 @@ + + <%= reading.label %> + <%= reading.grade %> +   + \ No newline at end of file diff --git a/app/views/mezuro_ranges/new.html.erb b/app/views/mezuro_ranges/new.html.erb index 7e1e453..4188389 100644 --- a/app/views/mezuro_ranges/new.html.erb +++ b/app/views/mezuro_ranges/new.html.erb @@ -1,7 +1,25 @@

New Range

- <%= form_for(@mezuro_range, :url => mezuro_configuration_metric_configuration_path(@mezuro_range.mezuro_configuration_id, @mezuro_range.metric_configuration_id)) do |f| %> <%= render partial: 'form', locals: {f: f} %> <% end %> + + + + + + + + + + + + <% if @reading_group.readings.size == 0 %> + <%= render partial: 'no_readings' %> + <% else %> + <%= render partial: 'reading', collection: @reading_group.readings, as: :reading %> + <% end %> + + +
LabelGradeColor
-- libgit2 0.21.2