From 2ca9dda6e8048e5971af7c3737996eef178fb756 Mon Sep 17 00:00:00 2001 From: João M. M. da Silva + Diego Araújo Date: Thu, 6 Sep 2012 10:44:23 -0300 Subject: [PATCH] [Mezuro] range controller refactored --- plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb | 2 -- plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb | 2 +- plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb | 4 ---- plugins/mezuro/test/functional/myprofile/mezuro_plugin_range_controller_test.rb | 3 +-- plugins/mezuro/views/mezuro_plugin_myprofile/_edit_range.html.erb | 4 ---- plugins/mezuro/views/mezuro_plugin_myprofile/_new_range.html.erb | 3 --- plugins/mezuro/views/mezuro_plugin_myprofile/_range.html.erb | 17 ----------------- plugins/mezuro/views/mezuro_plugin_myprofile/_range_form.html.erb | 61 ------------------------------------------------------------- plugins/mezuro/views/mezuro_plugin_myprofile/create_range.rjs | 2 -- plugins/mezuro/views/mezuro_plugin_myprofile/edit_compound_metric_configuration.html.erb | 2 +- plugins/mezuro/views/mezuro_plugin_myprofile/edit_metric_configuration.html.erb | 3 +-- plugins/mezuro/views/mezuro_plugin_myprofile/edit_range.rjs | 2 -- plugins/mezuro/views/mezuro_plugin_myprofile/new_range.rjs | 2 -- plugins/mezuro/views/mezuro_plugin_myprofile/update_range.rjs | 1 - plugins/mezuro/views/mezuro_plugin_range/_edit_range.html.erb | 4 ++++ plugins/mezuro/views/mezuro_plugin_range/_new_range.html.erb | 3 +++ plugins/mezuro/views/mezuro_plugin_range/_range.html.erb | 17 +++++++++++++++++ plugins/mezuro/views/mezuro_plugin_range/_range_form.html.erb | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ plugins/mezuro/views/mezuro_plugin_range/create_range.rjs | 2 ++ plugins/mezuro/views/mezuro_plugin_range/edit_range.rjs | 2 ++ plugins/mezuro/views/mezuro_plugin_range/new_range.rjs | 2 ++ plugins/mezuro/views/mezuro_plugin_range/update_range.rjs | 1 + 22 files changed, 96 insertions(+), 104 deletions(-) delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/_edit_range.html.erb delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/_new_range.html.erb delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/_range.html.erb delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/_range_form.html.erb delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/create_range.rjs delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/edit_range.rjs delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/new_range.rjs delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/update_range.rjs create mode 100644 plugins/mezuro/views/mezuro_plugin_range/_edit_range.html.erb create mode 100644 plugins/mezuro/views/mezuro_plugin_range/_new_range.html.erb create mode 100644 plugins/mezuro/views/mezuro_plugin_range/_range.html.erb create mode 100644 plugins/mezuro/views/mezuro_plugin_range/_range_form.html.erb create mode 100644 plugins/mezuro/views/mezuro_plugin_range/create_range.rjs create mode 100644 plugins/mezuro/views/mezuro_plugin_range/edit_range.rjs create mode 100644 plugins/mezuro/views/mezuro_plugin_range/new_range.rjs create mode 100644 plugins/mezuro/views/mezuro_plugin_range/update_range.rjs diff --git a/plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb b/plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb index 5a5a635..38748ff 100644 --- a/plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb +++ b/plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb @@ -109,8 +109,6 @@ class MezuroPluginMyprofileController < ProfileController end end - - private def redirect_to_error_page(message) diff --git a/plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb b/plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb index 4316f94..7d68d8a 100644 --- a/plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb +++ b/plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb @@ -1,6 +1,6 @@ class MezuroPluginRangeController < MezuroPluginMyprofileController - append_view_path File.join(File.dirname(__FILE__) + '/../views') + append_view_path File.join(File.dirname(__FILE__) + '/../../views') def new_range @configuration_content = profile.articles.find(params[:id]) diff --git a/plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb b/plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb index 937f4f8..e7023cf 100644 --- a/plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb +++ b/plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb @@ -5,7 +5,6 @@ require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/native_metric_fixtures" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/range_fixtures" class MezuroPluginMyprofileControllerTest < ActionController::TestCase @@ -35,9 +34,6 @@ class MezuroPluginMyprofileControllerTest < ActionController::TestCase @native_hash.delete :attributes! @compound_hash = @compound_metric_configuration.to_hash.merge({:configuration_name => @compound_metric_configuration.configuration_name}) @compound_hash.delete :attributes! - - @range = RangeFixtures.range_excellent - @range_hash = RangeFixtures.range_excellent_hash end should 'test choose base tool' do diff --git a/plugins/mezuro/test/functional/myprofile/mezuro_plugin_range_controller_test.rb b/plugins/mezuro/test/functional/myprofile/mezuro_plugin_range_controller_test.rb index 15e2df8..5bed6d0 100644 --- a/plugins/mezuro/test/functional/myprofile/mezuro_plugin_range_controller_test.rb +++ b/plugins/mezuro/test/functional/myprofile/mezuro_plugin_range_controller_test.rb @@ -1,7 +1,5 @@ require 'test_helper' -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/native_metric_fixtures" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" @@ -29,6 +27,7 @@ class MezuroPluginRangeControllerTest < ActionController::TestCase @range = RangeFixtures.range_excellent @range_hash = RangeFixtures.range_excellent_hash end + should 'test new range' do get :new_range, :profile => @profile.identifier, :id => @content.id, :metric_name => @metric.name assert_equal @content, assigns(:configuration_content) diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/_edit_range.html.erb b/plugins/mezuro/views/mezuro_plugin_myprofile/_edit_range.html.erb deleted file mode 100644 index 6dc8cc9..0000000 --- a/plugins/mezuro/views/mezuro_plugin_myprofile/_edit_range.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -<% remote_form_for :range, :url => {:action =>"update_range", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> - <%= hidden_field_tag :beginning_id, beginning_id %> - <%= render :partial => "range_form", :locals => {:f => f, :metric_name => metric_name, :id => id, :beginning_id => beginning_id, :range => range } %> -<% end %> diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/_new_range.html.erb b/plugins/mezuro/views/mezuro_plugin_myprofile/_new_range.html.erb deleted file mode 100644 index 62def0e..0000000 --- a/plugins/mezuro/views/mezuro_plugin_myprofile/_new_range.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% remote_form_for :range, :url => {:action =>"create_range", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> - <%= render :partial => "range_form", :locals => {:f => f, :metric_name => metric_name, :id => id } %> -<% end %> diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/_range.html.erb b/plugins/mezuro/views/mezuro_plugin_myprofile/_range.html.erb deleted file mode 100644 index 27fd6f1..0000000 --- a/plugins/mezuro/views/mezuro_plugin_myprofile/_range.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - - - <%=range.label%> - - - <%=range.beginning%> - - - <%=range.end%> - - - <%=range.grade%> - - - <%= link_to_remote "Edit", :url => {:action =>"edit_range", :controller => "mezuro_plugin_myprofile", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning} %> - <%= link_to "Remove", :action =>"remove_range", :controller => "mezuro_plugin_myprofile", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning %> - diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/_range_form.html.erb b/plugins/mezuro/views/mezuro_plugin_myprofile/_range_form.html.erb deleted file mode 100644 index 3ab3a72..0000000 --- a/plugins/mezuro/views/mezuro_plugin_myprofile/_range_form.html.erb +++ /dev/null @@ -1,61 +0,0 @@ -<%= hidden_field_tag :id, id %> -<%= hidden_field_tag :metric_name, metric_name %> - - - - - - - - - - - - - - - - - - - - - - - - - -
- <%= f.label :label, "(*) Label:" %> - - <%= f.text_field :label %> -
- <%= f.label :beginning, "(*) Beginning:" %> - - <%= f.text_field :beginning, :value => @range.beginning %> -
- <%= f.label :end, "(*) End:" %> - - <%= f.text_field :end, :value => @range.end %> -
- <%= f.label :grade, "(*) Grade:" %> - - <%= f.text_field :grade %> -
- <%= f.label :color, "(*) Color:" %> - - <%= f.text_field(:color, :id => "range_color", :value => @range.mezuro_color) %> -
- <%= f.label :comments, "Comments:" %> - - <%= f.text_field :comments %> -
-<%= f.submit "Save Range" %> - - diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/create_range.rjs b/plugins/mezuro/views/mezuro_plugin_myprofile/create_range.rjs deleted file mode 100644 index f0cf9ee..0000000 --- a/plugins/mezuro/views/mezuro_plugin_myprofile/create_range.rjs +++ /dev/null @@ -1,2 +0,0 @@ -page.visual_effect :toggle_slide, "range_form" -page.insert_html :bottom, "ranges", :partial => "range", :locals => {:range => @range} diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/edit_compound_metric_configuration.html.erb b/plugins/mezuro/views/mezuro_plugin_myprofile/edit_compound_metric_configuration.html.erb index 0bbd114..a123385 100644 --- a/plugins/mezuro/views/mezuro_plugin_myprofile/edit_compound_metric_configuration.html.erb +++ b/plugins/mezuro/views/mezuro_plugin_myprofile/edit_compound_metric_configuration.html.erb @@ -74,7 +74,7 @@
-<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_myprofile", :id => @configuration_content.id, :metric_name => @metric.name} %> +<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %>
diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/edit_metric_configuration.html.erb b/plugins/mezuro/views/mezuro_plugin_myprofile/edit_metric_configuration.html.erb index 3bb1ea8..75dd0df 100644 --- a/plugins/mezuro/views/mezuro_plugin_myprofile/edit_metric_configuration.html.erb +++ b/plugins/mezuro/views/mezuro_plugin_myprofile/edit_metric_configuration.html.erb @@ -83,7 +83,6 @@
-<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_myprofile", :id => @configuration_content.id, :metric_name => @metric.name} %> +<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %> - diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/edit_range.rjs b/plugins/mezuro/views/mezuro_plugin_myprofile/edit_range.rjs deleted file mode 100644 index 2358788..0000000 --- a/plugins/mezuro/views/mezuro_plugin_myprofile/edit_range.rjs +++ /dev/null @@ -1,2 +0,0 @@ -page.replace_html 'range_form', :partial => "edit_range", :locals => {:metric_name => @metric_name, :id => @configuration_content.id, :beginning_id => @beginning_id, :range => @range } -page.visual_effect :slide_down, "range_form" diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/new_range.rjs b/plugins/mezuro/views/mezuro_plugin_myprofile/new_range.rjs deleted file mode 100644 index fa13dee..0000000 --- a/plugins/mezuro/views/mezuro_plugin_myprofile/new_range.rjs +++ /dev/null @@ -1,2 +0,0 @@ -page.replace_html 'range_form', :partial => "new_range", :locals => {:metric_name => @metric_name, :id => @configuration_content.id } -page.visual_effect :slide_down, "range_form" diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/update_range.rjs b/plugins/mezuro/views/mezuro_plugin_myprofile/update_range.rjs deleted file mode 100644 index 5b95d3b..0000000 --- a/plugins/mezuro/views/mezuro_plugin_myprofile/update_range.rjs +++ /dev/null @@ -1 +0,0 @@ -page.reload() diff --git a/plugins/mezuro/views/mezuro_plugin_range/_edit_range.html.erb b/plugins/mezuro/views/mezuro_plugin_range/_edit_range.html.erb new file mode 100644 index 0000000..92b9a94 --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_range/_edit_range.html.erb @@ -0,0 +1,4 @@ +<% remote_form_for :range, :url => {:action =>"update_range", :controller => "mezuro_plugin_range"}, :method => :get do |f| %> + <%= hidden_field_tag :beginning_id, beginning_id %> + <%= render :partial => "range_form", :locals => {:f => f, :metric_name => metric_name, :id => id, :beginning_id => beginning_id, :range => range } %> +<% end %> diff --git a/plugins/mezuro/views/mezuro_plugin_range/_new_range.html.erb b/plugins/mezuro/views/mezuro_plugin_range/_new_range.html.erb new file mode 100644 index 0000000..245a782 --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_range/_new_range.html.erb @@ -0,0 +1,3 @@ +<% remote_form_for :range, :url => {:action =>"create_range", :controller => "mezuro_plugin_range"}, :method => :get do |f| %> + <%= render :partial => "range_form", :locals => {:f => f, :metric_name => metric_name, :id => id } %> +<% end %> diff --git a/plugins/mezuro/views/mezuro_plugin_range/_range.html.erb b/plugins/mezuro/views/mezuro_plugin_range/_range.html.erb new file mode 100644 index 0000000..97fbd52 --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_range/_range.html.erb @@ -0,0 +1,17 @@ + + + <%=range.label%> + + + <%=range.beginning%> + + + <%=range.end%> + + + <%=range.grade%> + + + <%= link_to_remote "Edit", :url => {:action =>"edit_range", :controller => "mezuro_plugin_range", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning} %> + <%= link_to "Remove", :action =>"remove_range", :controller => "mezuro_plugin_range", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning %> + diff --git a/plugins/mezuro/views/mezuro_plugin_range/_range_form.html.erb b/plugins/mezuro/views/mezuro_plugin_range/_range_form.html.erb new file mode 100644 index 0000000..3ab3a72 --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_range/_range_form.html.erb @@ -0,0 +1,61 @@ +<%= hidden_field_tag :id, id %> +<%= hidden_field_tag :metric_name, metric_name %> + + + + + + + + + + + + + + + + + + + + + + + + + +
+ <%= f.label :label, "(*) Label:" %> + + <%= f.text_field :label %> +
+ <%= f.label :beginning, "(*) Beginning:" %> + + <%= f.text_field :beginning, :value => @range.beginning %> +
+ <%= f.label :end, "(*) End:" %> + + <%= f.text_field :end, :value => @range.end %> +
+ <%= f.label :grade, "(*) Grade:" %> + + <%= f.text_field :grade %> +
+ <%= f.label :color, "(*) Color:" %> + + <%= f.text_field(:color, :id => "range_color", :value => @range.mezuro_color) %> +
+ <%= f.label :comments, "Comments:" %> + + <%= f.text_field :comments %> +
+<%= f.submit "Save Range" %> + + diff --git a/plugins/mezuro/views/mezuro_plugin_range/create_range.rjs b/plugins/mezuro/views/mezuro_plugin_range/create_range.rjs new file mode 100644 index 0000000..f0cf9ee --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_range/create_range.rjs @@ -0,0 +1,2 @@ +page.visual_effect :toggle_slide, "range_form" +page.insert_html :bottom, "ranges", :partial => "range", :locals => {:range => @range} diff --git a/plugins/mezuro/views/mezuro_plugin_range/edit_range.rjs b/plugins/mezuro/views/mezuro_plugin_range/edit_range.rjs new file mode 100644 index 0000000..2358788 --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_range/edit_range.rjs @@ -0,0 +1,2 @@ +page.replace_html 'range_form', :partial => "edit_range", :locals => {:metric_name => @metric_name, :id => @configuration_content.id, :beginning_id => @beginning_id, :range => @range } +page.visual_effect :slide_down, "range_form" diff --git a/plugins/mezuro/views/mezuro_plugin_range/new_range.rjs b/plugins/mezuro/views/mezuro_plugin_range/new_range.rjs new file mode 100644 index 0000000..fa13dee --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_range/new_range.rjs @@ -0,0 +1,2 @@ +page.replace_html 'range_form', :partial => "new_range", :locals => {:metric_name => @metric_name, :id => @configuration_content.id } +page.visual_effect :slide_down, "range_form" diff --git a/plugins/mezuro/views/mezuro_plugin_range/update_range.rjs b/plugins/mezuro/views/mezuro_plugin_range/update_range.rjs new file mode 100644 index 0000000..5b95d3b --- /dev/null +++ b/plugins/mezuro/views/mezuro_plugin_range/update_range.rjs @@ -0,0 +1 @@ +page.reload() -- libgit2 0.21.2