Commit ed0172e0bd36a62e824e94d2aa7465f8d888a6fa

Authored by Caio Salgado + Alessandro Palmeira
Committed by João da Silva
1 parent ec7d4270

[Mezuro] Fixed compound_metrics edition

plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb
@@ -59,17 +59,17 @@ class MezuroPluginMyprofileController < ProfileController @@ -59,17 +59,17 @@ class MezuroPluginMyprofileController < ProfileController
59 @configuration_name = params[:configuration_name] 59 @configuration_name = params[:configuration_name]
60 metric_name = params[:metric][:name] 60 metric_name = params[:metric][:name]
61 metric_configuration = Kalibro::Client::MetricConfigurationClient.new.metric_configuration(@configuration_name, metric_name) 61 metric_configuration = Kalibro::Client::MetricConfigurationClient.new.metric_configuration(@configuration_name, metric_name)
62 - assign_metric_configuration_instance (metric_configuration) 62 + metric_configuration = assign_metric_configuration_instance (metric_configuration)
63 Kalibro::Client::MetricConfigurationClient.new.save(metric_configuration, @configuration_name) 63 Kalibro::Client::MetricConfigurationClient.new.save(metric_configuration, @configuration_name)
64 redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" 64 redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}"
65 end 65 end
66 66
67 def update_compound_metric_configuration 67 def update_compound_metric_configuration
68 @configuration_name = params[:configuration_name] 68 @configuration_name = params[:configuration_name]
69 - metric_name = params[:metric][:name]  
70 - metric_configuration = Kalibro::Client::MetricConfigurationClient.new.metric_configuration(@configuration_name, metric_name)  
71 - assign_compound_metric_configuration_instance (metric_configuration)  
72 - Kalibro::Client::MetricConfigurationClient.new.save(metric_configuration, @configuration_name) 69 + metric_name = params[:metric_configuration][:metric][:name]
  70 + compound_metric_configuration = Kalibro::Client::MetricConfigurationClient.new.metric_configuration(@configuration_name, metric_name)
  71 + compound_metric_configuration = assign_compound_metric_configuration_instance (compound_metric_configuration)
  72 + Kalibro::Client::MetricConfigurationClient.new.save(compound_metric_configuration, @configuration_name)
73 redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" 73 redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}"
74 end 74 end
75 75
@@ -163,10 +163,10 @@ class MezuroPluginMyprofileController < ProfileController @@ -163,10 +163,10 @@ class MezuroPluginMyprofileController < ProfileController
163 end 163 end
164 164
165 def assign_compound_metric_configuration_instance (metric_configuration) 165 def assign_compound_metric_configuration_instance (metric_configuration)
166 - metric_configuration.metric.name = params[:metric_configuration][:metric_name]  
167 - metric_configuration.metric.description = params[:metric_configuration][:description]  
168 - metric_configuration.metric.scope = params[:metric_configuration][:scope]  
169 - metric_configuration.metric.script = params[:metric_configuration][:script] 166 + metric_configuration.metric.name = params[:metric_configuration][:metric][:name]
  167 + metric_configuration.metric.description = params[:metric_configuration][:metric][:description]
  168 + metric_configuration.metric.scope = params[:metric_configuration][:metric][:scope]
  169 + metric_configuration.metric.script = params[:metric_configuration][:metric][:script]
170 metric_configuration.code = params[:metric_configuration][:code] 170 metric_configuration.code = params[:metric_configuration][:code]
171 metric_configuration.weight = params[:metric_configuration][:weight] 171 metric_configuration.weight = params[:metric_configuration][:weight]
172 metric_configuration.aggregation_form = params[:metric_configuration][:aggregation_form] 172 metric_configuration.aggregation_form = params[:metric_configuration][:aggregation_form]
plugins/mezuro/views/mezuro_plugin_myprofile/edit_compound_metric_configuration.html.erb
1 <h2><%= @configuration_name %> Configuration</h2> 1 <h2><%= @configuration_name %> Configuration</h2>
2 2
3 -<% form_for @metric_configuration, :url => {:action =>"update_compound_metric_configuration", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> 3 +<% form_for :metric_configuration, :url => {:action =>"update_compound_metric_configuration", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %>
4 <%= hidden_field_tag :configuration_name, @configuration_name %> 4 <%= hidden_field_tag :configuration_name, @configuration_name %>
5 <p> 5 <p>
6 <%= "Metric Name:" + @metric.name %> 6 <%= "Metric Name:" + @metric.name %>
@@ -9,15 +9,15 @@ @@ -9,15 +9,15 @@
9 <%= m.hidden_field :name, :value => @metric.name %> 9 <%= m.hidden_field :name, :value => @metric.name %>
10 <p> 10 <p>
11 <%= m.label :description, "Description:" %> 11 <%= m.label :description, "Description:" %>
12 - <%= m.text_field "description" %> 12 + <%= m.text_field "description", :value => @metric.description %>
13 </p> 13 </p>
14 <p> 14 <p>
15 <%= m.label :scope, "Scope:" %> 15 <%= m.label :scope, "Scope:" %>
16 - <%= m.select :scope, [["Teste", "NIL"], ["Class", "CLASS"]] %> 16 + <%= m.select :scope, [["Class", "CLASS"]], :selected => @metric.scope %>
17 </p> 17 </p>
18 <p> 18 <p>
19 <%= m.label :script, "Script:" %> 19 <%= m.label :script, "Script:" %>
20 - <%= m.text_area "script" %> 20 + <%= m.text_area "script", :value => @metric.script %>
21 </p> 21 </p>
22 <% end %> 22 <% end %>
23 <p> 23 <p>