Commit 88490e5cd0eb559f8c49dc4b41368dbc4957e4f1

Authored by Alessandro Palmeira + João M. M. da Silva
Committed by Alessandro Palmeira
1 parent f83c66b0

[Mezuro] Saving ranges in metric_configuration

plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... ... @@ -77,6 +77,8 @@ class MezuroPluginProfileController < ProfileController
77 77 end
78 78  
79 79 def new_range
  80 + @metric_name = params[:metric_name]
  81 + @configuration_name = params[:configuration_name]
80 82 end
81 83  
82 84 def create_range
... ... @@ -87,6 +89,17 @@ class MezuroPluginProfileController < ProfileController
87 89 @range.grade = params[:range][:grade]
88 90 @range.color = params[:range][:color]
89 91 @range.comments = params[:range][:comments]
  92 +
  93 + configuration_name = params[:configuration_name]
  94 + metric_name = params[:metric_name]
  95 +
  96 + metric_configuration_client = Kalibro::Client::MetricConfigurationClient.new
  97 + metric_configuration = metric_configuration_client.metric_configuration(configuration_name, metric_name)
  98 +
  99 + metric_configuration.add_range(@range)
  100 +
  101 + metric_configuration_client.save(metric_configuration, configuration_name)
  102 +
90 103 end
91 104  
92 105 def remove_metric_configuration
... ...
plugins/mezuro/lib/kalibro/entities/metric_configuration.rb
... ... @@ -19,6 +19,11 @@ class Kalibro::Entities::MetricConfiguration < Kalibro::Entities::Entity
19 19 @range = to_entity_array(value, Kalibro::Entities::Range)
20 20 end
21 21  
  22 + def add_range(new_range)
  23 + @range = [] if @range.nil?
  24 + @range << new_range
  25 + end
  26 +
22 27 def ranges
23 28 @range
24 29 end
... ...
plugins/mezuro/views/mezuro_plugin_profile/_new_range.html.erb
1 1 <% remote_form_for :range, :url => {:action =>"create_range", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %>
2   - <%= hidden_field_tag :configuration_name, @configuration_name %>
3   - <%= hidden_field_tag :metric_name, @metric_name %>
  2 + <%= hidden_field_tag :configuration_name, configuration_name %>
  3 + <%= hidden_field_tag :metric_name, metric_name %>
4 4 <table>
5 5 <tr>
6 6 <td>
... ...
plugins/mezuro/views/mezuro_plugin_profile/edit_metric_configuration.html.erb
... ... @@ -72,6 +72,6 @@
72 72 </table>
73 73  
74 74 <br/>
75   -<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_profile"} %>
  75 +<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_profile", :configuration_name => @configuration_name, :metric_name => @metric.name} %>
76 76 <div id="new_range" style="display:none"></div>
77 77  
... ...
plugins/mezuro/views/mezuro_plugin_profile/new_range.rjs
1   -page.replace_html 'new_range', :partial => "new_range"
  1 +page.replace_html 'new_range', :partial => "new_range", :locals => {:metric_name => @metric_name, :configuration_name => @configuration_name}
2 2 page.visual_effect :toggle_slide, "new_range"
... ...