Commit 120750495c70df55e3d2182ee77c1aadfa622364
Committed by
Paulo Meireles
1 parent
de980e6a
Exists in
master
and in
28 other branches
[Mezuro] Clonning Configuration working, missing tests.
Showing
2 changed files
with
21 additions
and
2 deletions
Show diff stats
plugins/mezuro/lib/mezuro_plugin/configuration_content.rb
| ... | ... | @@ -121,7 +121,26 @@ class MezuroPlugin::ConfigurationContent < Article |
| 121 | 121 | end |
| 122 | 122 | |
| 123 | 123 | def clone_configuration |
| 124 | - #por enquanto não clona | |
| 124 | + metric_configurations_to_clone ||= Kalibro::MetricConfiguration.metric_configurations_of(configuration_to_clone_id) | |
| 125 | + clone_metric_configurations metric_configurations_to_clone | |
| 126 | + end | |
| 127 | + | |
| 128 | + def clone_metric_configurations metric_configurations_to_clone | |
| 129 | + metric_configurations_to_clone.each do |metric_configuration| | |
| 130 | + clonned_metric_configuration_id = metric_configuration.id | |
| 131 | + metric_configuration.id = nil | |
| 132 | + metric_configuration.configuration_id = self.configuration_id | |
| 133 | + metric_configuration.save | |
| 134 | + clone_ranges clonned_metric_configuration_id, metric_configuration.id | |
| 135 | + end | |
| 136 | + end | |
| 137 | + | |
| 138 | + def clone_ranges clonned_metric_configuration_id, new_metric_configuration_id | |
| 139 | + Kalibro::Range.ranges_of(clonned_metric_configuration_id).each do |range| | |
| 140 | + range.id = nil | |
| 141 | + range.save new_metric_configuration_id | |
| 142 | + end | |
| 125 | 143 | end |
| 126 | 144 | |
| 127 | 145 | end |
| 146 | + | ... | ... |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
| ... | ... | @@ -58,7 +58,7 @@ |
| 58 | 58 | <% end %> |
| 59 | 59 | <td><%= metric_configuration.code %></td> |
| 60 | 60 | <td><%= metric_configuration.weight %></td> |
| 61 | - <td><%= metric_configuration.aggreafation_form %></td> | |
| 61 | + <td><%= metric_configuration.aggregation_form %></td> | |
| 62 | 62 | <% if owner %> |
| 63 | 63 | <td><%= link_to "Remove", :controller => "mezuro_plugin_metric_configuration", :action => "remove_metric_configuration", |
| 64 | 64 | :metric_name => metric_configuration.metric.name, :id => @configuration_content.id, | ... | ... |