Commit 2ca9dda6e8048e5971af7c3737996eef178fb756

Authored by João M. M. da Silva + Diego Araújo
Committed by Paulo Meireles
1 parent 1f2785fc

[Mezuro] range controller refactored

Showing 22 changed files with 96 additions and 104 deletions   Show diff stats
plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb
... ... @@ -109,8 +109,6 @@ class MezuroPluginMyprofileController < ProfileController
109 109 end
110 110 end
111 111  
112   -
113   -
114 112 private
115 113  
116 114 def redirect_to_error_page(message)
... ...
plugins/mezuro/controllers/myprofile/mezuro_plugin_range_controller.rb
1 1 class MezuroPluginRangeController < MezuroPluginMyprofileController
2 2  
3   - append_view_path File.join(File.dirname(__FILE__) + '/../views')
  3 + append_view_path File.join(File.dirname(__FILE__) + '/../../views')
4 4  
5 5 def new_range
6 6 @configuration_content = profile.articles.find(params[:id])
... ...
plugins/mezuro/test/functional/mezuro_plugin_myprofile_controller_test.rb
... ... @@ -5,7 +5,6 @@ require &quot;#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures&quot;
5 5 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/native_metric_fixtures"
6 6 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures"
7 7 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures"
8   -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/range_fixtures"
9 8  
10 9 class MezuroPluginMyprofileControllerTest < ActionController::TestCase
11 10  
... ... @@ -35,9 +34,6 @@ class MezuroPluginMyprofileControllerTest &lt; ActionController::TestCase
35 34 @native_hash.delete :attributes!
36 35 @compound_hash = @compound_metric_configuration.to_hash.merge({:configuration_name => @compound_metric_configuration.configuration_name})
37 36 @compound_hash.delete :attributes!
38   -
39   - @range = RangeFixtures.range_excellent
40   - @range_hash = RangeFixtures.range_excellent_hash
41 37 end
42 38  
43 39 should 'test choose base tool' do
... ...
plugins/mezuro/test/functional/myprofile/mezuro_plugin_range_controller_test.rb
1 1 require 'test_helper'
2 2  
3   -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures"
4   -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures"
5 3 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/native_metric_fixtures"
6 4 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures"
7 5 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures"
... ... @@ -29,6 +27,7 @@ class MezuroPluginRangeControllerTest &lt; ActionController::TestCase
29 27 @range = RangeFixtures.range_excellent
30 28 @range_hash = RangeFixtures.range_excellent_hash
31 29 end
  30 +
32 31 should 'test new range' do
33 32 get :new_range, :profile => @profile.identifier, :id => @content.id, :metric_name => @metric.name
34 33 assert_equal @content, assigns(:configuration_content)
... ...
plugins/mezuro/views/mezuro_plugin_myprofile/_edit_range.html.erb
... ... @@ -1,4 +0,0 @@
1   -<% remote_form_for :range, :url => {:action =>"update_range", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %>
2   - <%= hidden_field_tag :beginning_id, beginning_id %>
3   - <%= render :partial => "range_form", :locals => {:f => f, :metric_name => metric_name, :id => id, :beginning_id => beginning_id, :range => range } %>
4   -<% end %>
plugins/mezuro/views/mezuro_plugin_myprofile/_new_range.html.erb
... ... @@ -1,3 +0,0 @@
1   -<% remote_form_for :range, :url => {:action =>"create_range", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %>
2   - <%= render :partial => "range_form", :locals => {:f => f, :metric_name => metric_name, :id => id } %>
3   -<% end %>
plugins/mezuro/views/mezuro_plugin_myprofile/_range.html.erb
... ... @@ -1,17 +0,0 @@
1   -<tr>
2   - <td>
3   - <%=range.label%>
4   - </td>
5   - <td>
6   - <%=range.beginning%>
7   - </td>
8   - <td>
9   - <%=range.end%>
10   - </td>
11   - <td>
12   - <%=range.grade%>
13   - </td>
14   - <td bgcolor="#<%= range.color[2..-1] %>"></td>
15   - <td><%= link_to_remote "Edit", :url => {:action =>"edit_range", :controller => "mezuro_plugin_myprofile", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning} %></td>
16   - <td><%= link_to "Remove", :action =>"remove_range", :controller => "mezuro_plugin_myprofile", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning %></td>
17   -</tr>
plugins/mezuro/views/mezuro_plugin_myprofile/_range_form.html.erb
... ... @@ -1,61 +0,0 @@
1   -<%= hidden_field_tag :id, id %>
2   -<%= hidden_field_tag :metric_name, metric_name %>
3   -<table>
4   - <tr>
5   - <td>
6   - <%= f.label :label, "(*) Label:" %>
7   - </td>
8   - <td>
9   - <%= f.text_field :label %>
10   - </td>
11   - </tr>
12   - <tr>
13   - <td>
14   - <%= f.label :beginning, "(*) Beginning:" %>
15   - </td>
16   - <td>
17   - <%= f.text_field :beginning, :value => @range.beginning %>
18   - </td>
19   - </tr>
20   - <tr>
21   - <td>
22   - <%= f.label :end, "(*) End:" %>
23   - </td>
24   - <td>
25   - <%= f.text_field :end, :value => @range.end %>
26   - </td>
27   - </tr>
28   - <tr>
29   - <td>
30   - <%= f.label :grade, "(*) Grade:" %>
31   - </td>
32   - <td>
33   - <%= f.text_field :grade %>
34   - </td>
35   - </tr>
36   - <tr>
37   - <td>
38   - <%= f.label :color, "(*) Color:" %>
39   - </td>
40   - <td>
41   - <%= f.text_field(:color, :id => "range_color", :value => @range.mezuro_color) %>
42   - </td>
43   - </tr>
44   - <tr>
45   - <td>
46   - <%= f.label :comments, "Comments:" %>
47   - </td>
48   - <td>
49   - <%= f.text_field :comments %>
50   - </td>
51   - </tr>
52   -</table>
53   -<%= f.submit "Save Range" %>
54   -
55   -<script>jQuery(document).ready(function($) {
56   - $('#range_color').colorPicker({
57   - onColorChange : function(id, newValue) {
58   - jQuery('#range_color').val(newValue);
59   - }
60   - });
61   -});</script>
plugins/mezuro/views/mezuro_plugin_myprofile/create_range.rjs
... ... @@ -1,2 +0,0 @@
1   -page.visual_effect :toggle_slide, "range_form"
2   -page.insert_html :bottom, "ranges", :partial => "range", :locals => {:range => @range}
plugins/mezuro/views/mezuro_plugin_myprofile/edit_compound_metric_configuration.html.erb
... ... @@ -74,7 +74,7 @@
74 74 </table>
75 75  
76 76 <br/>
77   -<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_myprofile", :id => @configuration_content.id, :metric_name => @metric.name} %>
  77 +<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %>
78 78 <div id="range_form" style="display:none"></div>
79 79  
80 80 <br/>
... ...
plugins/mezuro/views/mezuro_plugin_myprofile/edit_metric_configuration.html.erb
... ... @@ -83,7 +83,6 @@
83 83 </table>
84 84  
85 85 <br/>
86   -<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_myprofile", :id => @configuration_content.id, :metric_name => @metric.name} %>
  86 +<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %>
87 87 <div id="range_form" style="display:none"></div>
88 88  
89   -
... ...
plugins/mezuro/views/mezuro_plugin_myprofile/edit_range.rjs
... ... @@ -1,2 +0,0 @@
1   -page.replace_html 'range_form', :partial => "edit_range", :locals => {:metric_name => @metric_name, :id => @configuration_content.id, :beginning_id => @beginning_id, :range => @range }
2   -page.visual_effect :slide_down, "range_form"
plugins/mezuro/views/mezuro_plugin_myprofile/new_range.rjs
... ... @@ -1,2 +0,0 @@
1   -page.replace_html 'range_form', :partial => "new_range", :locals => {:metric_name => @metric_name, :id => @configuration_content.id }
2   -page.visual_effect :slide_down, "range_form"
plugins/mezuro/views/mezuro_plugin_myprofile/update_range.rjs
... ... @@ -1 +0,0 @@
1   -page.reload()
plugins/mezuro/views/mezuro_plugin_range/_edit_range.html.erb 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +<% remote_form_for :range, :url => {:action =>"update_range", :controller => "mezuro_plugin_range"}, :method => :get do |f| %>
  2 + <%= hidden_field_tag :beginning_id, beginning_id %>
  3 + <%= render :partial => "range_form", :locals => {:f => f, :metric_name => metric_name, :id => id, :beginning_id => beginning_id, :range => range } %>
  4 +<% end %>
... ...
plugins/mezuro/views/mezuro_plugin_range/_new_range.html.erb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<% remote_form_for :range, :url => {:action =>"create_range", :controller => "mezuro_plugin_range"}, :method => :get do |f| %>
  2 + <%= render :partial => "range_form", :locals => {:f => f, :metric_name => metric_name, :id => id } %>
  3 +<% end %>
... ...
plugins/mezuro/views/mezuro_plugin_range/_range.html.erb 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +<tr>
  2 + <td>
  3 + <%=range.label%>
  4 + </td>
  5 + <td>
  6 + <%=range.beginning%>
  7 + </td>
  8 + <td>
  9 + <%=range.end%>
  10 + </td>
  11 + <td>
  12 + <%=range.grade%>
  13 + </td>
  14 + <td bgcolor="#<%= range.color[2..-1] %>"></td>
  15 + <td><%= link_to_remote "Edit", :url => {:action =>"edit_range", :controller => "mezuro_plugin_range", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning} %></td>
  16 + <td><%= link_to "Remove", :action =>"remove_range", :controller => "mezuro_plugin_range", :id => params[:id], :metric_name => params[:metric_name], :beginning_id => range.beginning %></td>
  17 +</tr>
... ...
plugins/mezuro/views/mezuro_plugin_range/_range_form.html.erb 0 → 100644
... ... @@ -0,0 +1,61 @@
  1 +<%= hidden_field_tag :id, id %>
  2 +<%= hidden_field_tag :metric_name, metric_name %>
  3 +<table>
  4 + <tr>
  5 + <td>
  6 + <%= f.label :label, "(*) Label:" %>
  7 + </td>
  8 + <td>
  9 + <%= f.text_field :label %>
  10 + </td>
  11 + </tr>
  12 + <tr>
  13 + <td>
  14 + <%= f.label :beginning, "(*) Beginning:" %>
  15 + </td>
  16 + <td>
  17 + <%= f.text_field :beginning, :value => @range.beginning %>
  18 + </td>
  19 + </tr>
  20 + <tr>
  21 + <td>
  22 + <%= f.label :end, "(*) End:" %>
  23 + </td>
  24 + <td>
  25 + <%= f.text_field :end, :value => @range.end %>
  26 + </td>
  27 + </tr>
  28 + <tr>
  29 + <td>
  30 + <%= f.label :grade, "(*) Grade:" %>
  31 + </td>
  32 + <td>
  33 + <%= f.text_field :grade %>
  34 + </td>
  35 + </tr>
  36 + <tr>
  37 + <td>
  38 + <%= f.label :color, "(*) Color:" %>
  39 + </td>
  40 + <td>
  41 + <%= f.text_field(:color, :id => "range_color", :value => @range.mezuro_color) %>
  42 + </td>
  43 + </tr>
  44 + <tr>
  45 + <td>
  46 + <%= f.label :comments, "Comments:" %>
  47 + </td>
  48 + <td>
  49 + <%= f.text_field :comments %>
  50 + </td>
  51 + </tr>
  52 +</table>
  53 +<%= f.submit "Save Range" %>
  54 +
  55 +<script>jQuery(document).ready(function($) {
  56 + $('#range_color').colorPicker({
  57 + onColorChange : function(id, newValue) {
  58 + jQuery('#range_color').val(newValue);
  59 + }
  60 + });
  61 +});</script>
... ...
plugins/mezuro/views/mezuro_plugin_range/create_range.rjs 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +page.visual_effect :toggle_slide, "range_form"
  2 +page.insert_html :bottom, "ranges", :partial => "range", :locals => {:range => @range}
... ...
plugins/mezuro/views/mezuro_plugin_range/edit_range.rjs 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +page.replace_html 'range_form', :partial => "edit_range", :locals => {:metric_name => @metric_name, :id => @configuration_content.id, :beginning_id => @beginning_id, :range => @range }
  2 +page.visual_effect :slide_down, "range_form"
... ...
plugins/mezuro/views/mezuro_plugin_range/new_range.rjs 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +page.replace_html 'range_form', :partial => "new_range", :locals => {:metric_name => @metric_name, :id => @configuration_content.id }
  2 +page.visual_effect :slide_down, "range_form"
... ...
plugins/mezuro/views/mezuro_plugin_range/update_range.rjs 0 → 100644
... ... @@ -0,0 +1 @@
  1 +page.reload()
... ...