Commit db501ebee70e191dcff42104a321f986b7bd3a04
Committed by
Paulo Meireles
1 parent
34a1e40f
Exists in
master
and in
29 other branches
[Mezuro] Finished metric_configuration (missing some functional tests)
Showing
12 changed files
with
192 additions
and
224 deletions
Show diff stats
plugins/mezuro/controllers/myprofile/mezuro_plugin_metric_configuration_controller.rb
... | ... | @@ -34,73 +34,64 @@ class MezuroPluginMetricConfigurationController < MezuroPluginMyprofileControlle |
34 | 34 | @metric = @metric_configuration.metric |
35 | 35 | @reading_group_names_and_ids = reading_group_names_and_ids |
36 | 36 | end |
37 | -=begin | |
38 | - def new_compound_metric_configuration | |
39 | - @configuration_content = profile.articles.find(params[:id]) | |
40 | - @metric_configurations = @configuration_content.metric_configurations | |
41 | - if configuration_content_has_errors? | |
42 | - redirect_to_error_page @configuration_content.errors[:base] | |
43 | - end | |
44 | - end | |
45 | - | |
46 | 37 | |
47 | - def edit_compound_metric_configuration | |
38 | + def update | |
48 | 39 | @configuration_content = profile.articles.find(params[:id]) |
49 | - @metric_configuration = Kalibro::MetricConfiguration.find_by_configuration_name_and_metric_name(@configuration_content.name, params[:metric_name]) | |
50 | - @metric_configurations = @configuration_content.metric_configurations | |
51 | - @metric = @metric_configuration.metric | |
52 | - end | |
53 | - | |
54 | - | |
55 | - def create_compound_metric_configuration | |
56 | - id = params[:id] | |
57 | - metric_name = params[:metric_configuration][:metric][:name] | |
58 | - metric_configuration = Kalibro::MetricConfiguration.new(params[:metric_configuration]) | |
59 | - metric_configuration.save | |
40 | + configuration_id = @configuration_content.configuration_id | |
41 | + metric_configurations = Kalibro::MetricConfiguration.metric_configurations_of(configuration_id) | |
42 | + metric_configuration = find_metric_configuration(metric_configurations, params[:metric_configuration][:id].to_i) | |
43 | + metric_configuration.update_attributes params[:metric_configuration] | |
60 | 44 | if metric_configuration_has_errors? metric_configuration |
61 | 45 | redirect_to_error_page metric_configuration.errors[0].message |
62 | 46 | else |
63 | - redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/metric_configuration/edit_compound_metric_configuration?id=#{id}&metric_name=#{metric_name.gsub(/\s/, '+')}" | |
47 | + redirect_to "/#{profile.identifier}/#{@configuration_content.slug}" | |
64 | 48 | end |
65 | 49 | end |
66 | 50 | |
67 | - def update_metric_configuration | |
68 | - @configuration_content = profile.articles.find(params[:id]) | |
69 | - metric_name = params[:metric_configuration][:metric][:name] | |
70 | - metric_configuration = Kalibro::MetricConfiguration.find_by_configuration_name_and_metric_name(@configuration_content.name, metric_name) | |
71 | - metric_configuration.update_attributes params[:metric_configuration] | |
51 | + def remove | |
52 | + configuration_content = profile.articles.find(params[:id]) | |
53 | + configuration_id = configuration_content.configuration_id | |
54 | + metric_configurations = Kalibro::MetricConfiguration.metric_configurations_of(configuration_id) | |
55 | + metric_configuration = find_metric_configuration(metric_configurations, params[:metric_configuration_id].to_i) | |
56 | + metric_configuration.destroy | |
72 | 57 | if metric_configuration_has_errors? metric_configuration |
73 | 58 | redirect_to_error_page metric_configuration.errors[0].message |
74 | 59 | else |
75 | - redirect_to "/#{profile.identifier}/#{@configuration_content.slug}" | |
60 | + redirect_to "/#{profile.identifier}/#{configuration_content.slug}" | |
76 | 61 | end |
77 | 62 | end |
78 | - | |
79 | - def update_compound_metric_configuration | |
63 | + | |
64 | + def new_compound | |
80 | 65 | @configuration_content = profile.articles.find(params[:id]) |
81 | - metric_name = params[:metric_configuration][:metric][:name] | |
82 | - metric_configuration = Kalibro::MetricConfiguration.find_by_configuration_name_and_metric_name(@configuration_content.name, metric_name) | |
83 | - metric_configuration.update_attributes params[:metric_configuration] | |
84 | - if metric_configuration_has_errors? metric_configuration | |
85 | - redirect_to_error_page metric_configuration.errors[0].message | |
86 | - else | |
87 | - redirect_to "/#{profile.identifier}/#{@configuration_content.slug}" | |
66 | + @metric_configurations = @configuration_content.metric_configurations | |
67 | + @reading_group_names_and_ids = reading_group_names_and_ids | |
68 | + if configuration_content_has_errors? | |
69 | + redirect_to_error_page @configuration_content.errors[:base] | |
88 | 70 | end |
89 | 71 | end |
90 | 72 | |
91 | - def remove_metric_configuration | |
92 | - configuration_content = profile.articles.find(params[:id]) | |
93 | - metric_name = params[:metric_name] | |
94 | - metric_configuration = Kalibro::MetricConfiguration.find_by_configuration_name_and_metric_name(configuration_content.name, metric_name) | |
95 | - metric_configuration.destroy | |
73 | + def create_compound | |
74 | + metric_configuration = Kalibro::MetricConfiguration.new(params[:metric_configuration]) | |
75 | + metric_configuration.save | |
76 | + | |
96 | 77 | if metric_configuration_has_errors? metric_configuration |
97 | 78 | redirect_to_error_page metric_configuration.errors[0].message |
98 | 79 | else |
99 | - redirect_to "/#{profile.identifier}/#{configuration_content.slug}" | |
80 | + id = params[:id] | |
81 | + redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/metric_configuration/edit_compound?id=#{id}&metric_configuration_id=#{metric_configuration.id}" | |
100 | 82 | end |
101 | 83 | end |
102 | -=end | |
103 | - | |
84 | + | |
85 | + def edit_compound | |
86 | + @configuration_content = profile.articles.find(params[:id]) | |
87 | + configuration_id = @configuration_content.configuration_id | |
88 | + metric_configurations = Kalibro::MetricConfiguration.metric_configurations_of(configuration_id) | |
89 | + @metric_configuration = find_metric_configuration(metric_configurations, params[:metric_configuration_id].to_i) | |
90 | + @metric = @metric_configuration.metric | |
91 | + @reading_group_names_and_ids = reading_group_names_and_ids | |
92 | + @metric_configurations = metric_configurations | |
93 | + end | |
94 | + | |
104 | 95 | private |
105 | 96 | |
106 | 97 | def find_metric_configuration (metric_configurations, metric_configuration_id) | ... | ... |
plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb
plugins/mezuro/test/functional/myprofile/mezuro_plugin_metric_configuration_controller_test.rb
... | ... | @@ -12,7 +12,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
12 | 12 | @controller = MezuroPluginMetricConfigurationController.new |
13 | 13 | @request = ActionController::TestRequest.new |
14 | 14 | @response = ActionController::TestResponse.new |
15 | - @profile = fast_create(Community) | |
15 | + @profile = fast_create(Community) #FIXME Should be a person, not a community | |
16 | 16 | |
17 | 17 | @configuration = ConfigurationFixtures.configuration |
18 | 18 | @created_configuration = ConfigurationFixtures.created_configuration |
... | ... | @@ -34,8 +34,8 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
34 | 34 | @metric_configuration = MetricConfigurationFixtures.amloc_metric_configuration |
35 | 35 | @metric_configuration_hash = MetricConfigurationFixtures.amloc_metric_configuration_hash |
36 | 36 | @created_metric_configuration = MetricConfigurationFixtures.created_metric_configuration |
37 | -=begin | |
38 | 37 | @compound_metric_configuration = MetricConfigurationFixtures.sc_metric_configuration |
38 | +=begin | |
39 | 39 | @compound_metric_configuration_hash = MetricConfigurationFixtures.sc_metric_configuration_hash |
40 | 40 | |
41 | 41 | |
... | ... | @@ -46,7 +46,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
46 | 46 | =end |
47 | 47 | end |
48 | 48 | |
49 | - should 'test choose metric' do | |
49 | + should 'choose metric' do | |
50 | 50 | Kalibro::BaseTool.expects(:all).returns([@base_tool]) |
51 | 51 | get :choose_metric, :profile => @profile.identifier, :id => @configuration_content.id |
52 | 52 | assert_equal @configuration_content, assigns(:configuration_content) |
... | ... | @@ -54,7 +54,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
54 | 54 | assert_response 200 |
55 | 55 | end |
56 | 56 | |
57 | - should 'test new native metric configuration' do | |
57 | + should 'initialize native' do | |
58 | 58 | Kalibro::BaseTool.expects(:find_by_name).with(@base_tool.name).returns(@base_tool) |
59 | 59 | Kalibro::ReadingGroup.expects(:all).returns([@reading_group]) |
60 | 60 | get :new_native, :profile => @profile.identifier, :id => @configuration_content.id, :base_tool_name => @base_tool.name, :metric_name => @metric.name |
... | ... | @@ -65,7 +65,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
65 | 65 | assert_response 200 |
66 | 66 | end |
67 | 67 | |
68 | - should 'test create native metric configuration' do | |
68 | + should 'create native' do | |
69 | 69 | #Kalibro::MetricConfiguration.expects(:new).returns(@created_metric_configuration) #FIXME need .with(some_hash). |
70 | 70 | #@created_metric_configuration.expects(:save).returns(true) |
71 | 71 | =begin |
... | ... | @@ -76,7 +76,7 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
76 | 76 | =end |
77 | 77 | end |
78 | 78 | |
79 | - should 'test edit native metric configuration' do | |
79 | + should 'edit native' do | |
80 | 80 | Kalibro::MetricConfiguration.expects(:metric_configurations_of).with(@configuration.id).returns([@metric_configuration]) |
81 | 81 | Kalibro::ReadingGroup.expects(:all).returns([@reading_group]) |
82 | 82 | get :edit_native, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id |
... | ... | @@ -86,18 +86,31 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
86 | 86 | assert_equal [[@reading_group.name,@reading_group.id]], assigns(:reading_group_names_and_ids) |
87 | 87 | assert_response 200 |
88 | 88 | end |
89 | -=begin | |
90 | - should 'test new compound metric configuration' do | |
91 | - Kalibro::Configuration.expects(:request).with("Configuration", :get_configuration, { | |
92 | - :configuration_name => @configuration_content.name}).returns({:configuration => @configuration_hash}) | |
93 | - get :new_compound_metric_configuration, :profile => @profile.identifier, :id => @configuration_content.id | |
89 | + | |
90 | + should 'initialize compound' do | |
91 | + Kalibro::ReadingGroup.expects(:all).returns([@reading_group]) | |
92 | + get :new_compound, :profile => @profile.identifier, :id => @configuration_content.id | |
94 | 93 | assert_equal @configuration_content, assigns(:configuration_content) |
95 | - assert_equal @configuration.metric_configuration[0].code, assigns(:metric_configurations)[0].code | |
94 | + #FIXME mock is not working. configuration_id is not being set. | |
95 | + #MezuroPlugin::ConfigurationContent.expects(:metric_configurations).returns([@compound_metric_configuration]) | |
96 | + #assert_equal @compound_metric_configuration.code, assigns(:metric_configurations).first.code | |
97 | + assert_equal [[@reading_group.name,@reading_group.id]], assigns(:reading_group_names_and_ids) | |
96 | 98 | assert_response 200 |
97 | 99 | end |
98 | 100 | |
99 | - | |
100 | - should 'test edit compound metric configuration' do | |
101 | + should 'create compound' do | |
102 | +=begin TODO ARRUMAR ESTE TESTE!!! | |
103 | + Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :save_metric_configuration, { | |
104 | + :metric_configuration => @compound_metric_configuration.to_hash, | |
105 | + :configuration_name => @compound_metric_configuration.configuration_name}) | |
106 | + get :create_compound_metric_configuration, :profile => @profile.identifier, :id => @configuration_content.id, | |
107 | + :metric_configuration => @compound_hash | |
108 | + assert_response 302 | |
109 | +=end | |
110 | + end | |
111 | + | |
112 | + should 'edit compound' do | |
113 | +=begin TODO ARRUMAR ESTE TESTE!!! | |
101 | 114 | Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :get_metric_configuration, { |
102 | 115 | :configuration_name => @configuration_content.name, |
103 | 116 | :metric_name => @compound_metric_configuration.metric.name}).returns({:metric_configuration => @compound_metric_configuration_hash}) |
... | ... | @@ -111,19 +124,11 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
111 | 124 | assert_equal @compound_metric_configuration.metric.name, assigns(:metric).name |
112 | 125 | assert_equal @configuration.metric_configuration[0].code, assigns(:metric_configurations)[0].code |
113 | 126 | assert_response 200 |
127 | +=end | |
114 | 128 | end |
115 | 129 | |
116 | - | |
117 | - should 'test compound metric creation' do | |
118 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :save_metric_configuration, { | |
119 | - :metric_configuration => @compound_metric_configuration.to_hash, | |
120 | - :configuration_name => @compound_metric_configuration.configuration_name}) | |
121 | - get :create_compound_metric_configuration, :profile => @profile.identifier, :id => @configuration_content.id, | |
122 | - :metric_configuration => @compound_hash | |
123 | - assert_response 302 | |
124 | - end | |
125 | - | |
126 | - should 'test update native metric configuration' do | |
130 | + should 'update' do | |
131 | +=begin TODO ARRUMAR ESTE TESTE!!! | |
127 | 132 | Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :get_metric_configuration, { |
128 | 133 | :configuration_name => @configuration_content.name, |
129 | 134 | :metric_name => @metric_configuration.metric.name}).returns({:metric_configuration => @metric_configuration_hash}) |
... | ... | @@ -134,30 +139,15 @@ class MezuroPluginMetricConfigurationControllerTest < ActionController::TestCase |
134 | 139 | :metric_configuration => @native_hash |
135 | 140 | assert_equal @configuration_content, assigns(:configuration_content) |
136 | 141 | assert_response 302 |
142 | +=end | |
137 | 143 | end |
138 | - | |
139 | - should 'test update compound metric configuration' do | |
140 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :get_metric_configuration, { | |
141 | - :configuration_name => @configuration_content.name, | |
142 | - :metric_name => @compound_metric_configuration.metric.name}).returns({:metric_configuration => @compound_metric_configuration_hash}) | |
143 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :save_metric_configuration, { | |
144 | - :metric_configuration => @compound_metric_configuration.to_hash, | |
145 | - :configuration_name => @compound_metric_configuration.configuration_name}) | |
146 | - get :update_compound_metric_configuration, :profile => @profile.identifier, :id => @configuration_content.id, | |
147 | - :metric_configuration => @compound_hash | |
148 | - assert_equal @configuration_content, assigns(:configuration_content) | |
144 | + | |
145 | + should 'remove' do | |
146 | + Kalibro::MetricConfiguration.expects(:metric_configurations_of).with(@configuration.id).returns([@metric_configuration]) | |
147 | + @metric_configuration.expects(:destroy).returns() | |
148 | + get :remove, :profile => @profile.identifier, :id => @configuration_content.id, :metric_configuration_id => @metric_configuration.id | |
149 | 149 | assert_response 302 |
150 | 150 | end |
151 | 151 | |
152 | - should 'test remove metric configuration' do | |
153 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :get_metric_configuration, { | |
154 | - :configuration_name => @configuration_content.name, | |
155 | - :metric_name => @metric.name}).returns({:metric_configuration => @metric_configuration_hash}) | |
156 | - Kalibro::MetricConfiguration.expects(:request).with("MetricConfiguration", :remove_metric_configuration, { | |
157 | - :metric_name => @metric.name, | |
158 | - :configuration_name => @metric_configuration.configuration_name}) | |
159 | - get :remove_metric_configuration, :profile => @profile.identifier, :id => @configuration_content.id, :metric_name => @metric.name | |
160 | - assert_response 302 | |
161 | - end | |
162 | -=end | |
152 | + | |
163 | 153 | end | ... | ... |
plugins/mezuro/test/unit/mezuro_plugin/helpers/content_viewer_helper_test.rb
... | ... | @@ -60,4 +60,8 @@ class ContentViewerHelperTest < ActiveSupport::TestCase |
60 | 60 | ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]], @helper.aggregation_options |
61 | 61 | end |
62 | 62 | |
63 | + should 'create scope options' do | |
64 | + assert_equal [["Class", "CLASS"]], @helper.scope_options | |
65 | + end | |
66 | + | |
63 | 67 | end | ... | ... |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
... | ... | @@ -44,7 +44,13 @@ |
44 | 44 | </tr> |
45 | 45 | <% @configuration_content.metric_configurations.each do |metric_configuration| %> |
46 | 46 | <tr class="metric"> |
47 | - <td><%= link_to metric_configuration.metric.name, :controller => "mezuro_plugin_metric_configuration", :action => "edit_native", | |
47 | + <% if metric_configuration.metric.compound | |
48 | + edit_action = "edit_compound" | |
49 | + else | |
50 | + edit_action = "edit_native" | |
51 | + end | |
52 | + %> | |
53 | + <td><%= link_to metric_configuration.metric.name, :controller => "mezuro_plugin_metric_configuration", :action => edit_action, | |
48 | 54 | :metric_configuration_id => metric_configuration.id, :id => @configuration_content.id, |
49 | 55 | :profile => @page.profile.identifier %></td> |
50 | 56 | <% if metric_configuration.metric.compound %> |
... | ... | @@ -60,8 +66,8 @@ |
60 | 66 | <td><%= metric_configuration.weight %></td> |
61 | 67 | <td><%= metric_configuration.aggregation_form %></td> |
62 | 68 | <% if owner %> |
63 | - <td><%= link_to "Remove", :controller => "mezuro_plugin_metric_configuration", :action => "remove_metric_configuration", | |
64 | - :metric_name => metric_configuration.metric.name, :id => @configuration_content.id, | |
69 | + <td><%= link_to "Remove", :controller => "mezuro_plugin_metric_configuration", :action => "remove", | |
70 | + :metric_configuration_id => metric_configuration.id, :id => @configuration_content.id, | |
65 | 71 | :profile => @page.profile.identifier %></td> |
66 | 72 | <% end %> |
67 | 73 | </tr> | ... | ... |
plugins/mezuro/views/mezuro_plugin_metric_configuration/_native_metric_configuration_form.rhtml
1 | -<% form_for :metric_configuration, :url => {:action =>"update_native", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
1 | +<% form_for :metric_configuration, :url => {:action =>"update", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
2 | 2 | <%= hidden_field_tag :id, @configuration_content.id %> |
3 | 3 | <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %> |
4 | 4 | <%= f.hidden_field :id, :value => @metric_configuration.id %> |
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | <%= labelled_form_field _('Collector Name:'), f.text_field(:base_tool_name, :value => @base_tool_name, :readonly => true) %> |
7 | 7 | |
8 | 8 | <% f.fields_for :metric do |m| %> |
9 | + <%= m.hidden_field :compound, :value => "false" %> | |
9 | 10 | <% @metric.language.each do |language| %> |
10 | 11 | <%= m.hidden_field :language, :multiple => true, :value => language %> |
11 | 12 | <% end %> |
... | ... | @@ -17,12 +18,13 @@ |
17 | 18 | <%= required labelled_form_field _('Code:'), f.text_field(:code) %> |
18 | 19 | |
19 | 20 | <%= required labelled_form_field _('Aggregation Form:'), |
20 | - f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options) %> | |
21 | + f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options, | |
22 | + :selected => @metric_configuration.aggregation_form ) %> | |
21 | 23 | |
22 | 24 | <%= required labelled_form_field _('Weight:'), f.text_field(:weight) %> |
23 | 25 | |
24 | 26 | <%= required labelled_form_field _('Reading Group:'), |
25 | - f.select(:reading_group_id, @reading_group_names_and_ids) %> | |
27 | + f.select(:reading_group_id, @reading_group_names_and_ids, :selected => @metric_configuration.reading_group_id.to_i) %> | |
26 | 28 | |
27 | 29 | <p> |
28 | 30 | <%= f.submit "Save" %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_metric_configuration/choose_metric.html.erb
1 | 1 | <h2><%= @configuration_content.name%> Configuration</h2> |
2 | 2 | |
3 | -<%= link_to "New Compound Metric", :controller => "mezuro_plugin_metric_configuration", :action => "new_compound_metric_configuration", | |
3 | +<%= link_to "New Compound Metric", :controller => "mezuro_plugin_metric_configuration", :action => "new_compound", | |
4 | 4 | :id => @configuration_content.id %> |
5 | 5 | |
6 | 6 | <h5>Base Tools:</h5> | ... | ... |
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_compound.html.erb
0 → 100644
... | ... | @@ -0,0 +1,69 @@ |
1 | +<script src="/plugins/mezuro/javascripts/validations.js" type="text/javascript"></script> | |
2 | +<script src="/javascripts/colorpicker.js" type="text/javascript"></script> | |
3 | +<script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> | |
4 | + | |
5 | +<h2><%= @configuration_content.name %> Configuration</h2> | |
6 | + | |
7 | +<% form_for :metric_configuration, :url => {:action =>"update", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
8 | + <%= hidden_field_tag :id, @configuration_content.id %> | |
9 | + <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %> | |
10 | + <%= f.hidden_field :id, :value => @metric_configuration.id %> | |
11 | + | |
12 | + <% f.fields_for :metric do |m| %> | |
13 | + <%= m.hidden_field :compound, :value => "true" %> | |
14 | + <%= required labelled_form_field _('Metric Name:'), m.text_field(:name, :value => @metric.name) %> | |
15 | + <%= labelled_form_field _('Description:'), m.text_field(:description, :value => @metric.description) %> | |
16 | + <%= required labelled_form_field _('Script:'), m.text_area(:script, :rows => 5, :value => @metric.script) %> | |
17 | + <%= required labelled_form_field _('Scope:'), | |
18 | + m.select(:scope, MezuroPlugin::Helpers::ContentViewerHelper.scope_options, :selected => @metric.scope) %> | |
19 | + <% end %> | |
20 | + | |
21 | + <%= required labelled_form_field _('Code:'), f.text_field(:code), :value => @metric_configuration.code %> | |
22 | + <%= required labelled_form_field _('Aggregation Form:'), | |
23 | + f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options, | |
24 | + :selected => @metric_configuration.aggregation_form ) %> | |
25 | + <%= required labelled_form_field _('Weight:'), f.text_field(:weight), :value => @metric_configuration.weight %> | |
26 | + <%= required labelled_form_field _('Reading Group:'), f.select(:reading_group_id, @reading_group_names_and_ids, | |
27 | + :selected => @metric_configuration.reading_group_id.to_i) %> | |
28 | + | |
29 | + <p><%= f.submit "Save" %></p> | |
30 | + | |
31 | +<% end %> | |
32 | + | |
33 | +<h5> Ranges </h5><br/> | |
34 | + | |
35 | +<table id="ranges"> | |
36 | + <tr> | |
37 | + <td> | |
38 | + Label | |
39 | + </td> | |
40 | + <td> | |
41 | + Beginning | |
42 | + </td> | |
43 | + <td> | |
44 | + End | |
45 | + </td> | |
46 | + <td> | |
47 | + Grade | |
48 | + </td> | |
49 | + <td> | |
50 | + Color | |
51 | + </td> | |
52 | + </tr> | |
53 | + <% | |
54 | + #if (@metric_configuration.ranges!=nil) | |
55 | + # @metric_configuration.ranges.each do |range| | |
56 | + %> | |
57 | + <%= #render :partial => "mezuro_plugin_range/range", :locals => {:range => range, :id => @configuration_content.id, | |
58 | + #:metric_name => @metric_configuration.metric.name} | |
59 | + %> | |
60 | + <% #end | |
61 | + #end | |
62 | + %> | |
63 | +</table> | |
64 | + | |
65 | +<br/> | |
66 | +<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %> | |
67 | +<div id="range_form" style="display:none"></div> | |
68 | +<br/> | |
69 | +<%= render :partial => "metric_codes", :locals => {:metric_configurations => @metric_configurations} %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_metric_configuration/edit_compound_metric_configuration.html.erb
... | ... | @@ -1,81 +0,0 @@ |
1 | -<script src="/plugins/mezuro/javascripts/validations.js" type="text/javascript"></script> | |
2 | -<script src="/javascripts/colorpicker.js" type="text/javascript"></script> | |
3 | -<script src="/javascripts/colorpicker-noosfero.js" type="text/javascript"></script> | |
4 | - | |
5 | -<h2><%= @configuration_content.name %> Configuration</h2> | |
6 | - | |
7 | -<% form_for :metric_configuration, :url => {:action =>"update_compound_metric_configuration", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
8 | - <%= hidden_field_tag :id, @configuration_content.id %> | |
9 | - <%= f.hidden_field :configuration_name, :value => @configuration_content.name %> | |
10 | - | |
11 | - <p> | |
12 | - <%= "Metric Name:" + @metric.name %> | |
13 | - </p> | |
14 | - <% f.fields_for :metric do |m| %> | |
15 | - <%= m.hidden_field :name, :value => @metric.name %> | |
16 | - <p> | |
17 | - <%= m.label :description, "Description:" %> | |
18 | - <%= m.text_field "description", :value => @metric.description %> | |
19 | - </p> | |
20 | - <p> | |
21 | - <%= m.label :scope, "Scope:" %> | |
22 | - <%= m.select :scope, [["Class", "CLASS"]], :selected => @metric.scope %> | |
23 | - </p> | |
24 | - <p> | |
25 | - <%= m.label :script, "Script:" %> | |
26 | - <%= m.text_area "script", :value => @metric.script, :rows => 5 %> | |
27 | - </p> | |
28 | - <% end %> | |
29 | - <p> | |
30 | - <%= f.label :code, "Code:" %> | |
31 | - <%= f.text_field "code" %> | |
32 | - </p> | |
33 | - <p> | |
34 | - <%= f.label :aggregation_form, "Aggregation Form:" %> | |
35 | - <%= f.select :aggregation_form, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | |
36 | - ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %> | |
37 | - </p> | |
38 | - <p> | |
39 | - <%= f.label :weight, "Weight:" %> | |
40 | - <%= f.text_field :weight %> | |
41 | - </p> | |
42 | - <p> | |
43 | - <%= f.submit "Save" %> | |
44 | - </p> | |
45 | -<% end %> | |
46 | - | |
47 | - | |
48 | -<h5> Ranges </h5><br/> | |
49 | - | |
50 | -<table id="ranges"> | |
51 | - <tr> | |
52 | - <td> | |
53 | - Label | |
54 | - </td> | |
55 | - <td> | |
56 | - Beginning | |
57 | - </td> | |
58 | - <td> | |
59 | - End | |
60 | - </td> | |
61 | - <td> | |
62 | - Grade | |
63 | - </td> | |
64 | - <td> | |
65 | - Color | |
66 | - </td> | |
67 | - </tr> | |
68 | - <% if (@metric_configuration.ranges!=nil) | |
69 | - @metric_configuration.ranges.each do |range| %> | |
70 | - <%= render :partial => "mezuro_plugin_range/range", :locals => {:range => range, :id => @configuration_content.id, | |
71 | - :metric_name => @metric_configuration.metric.name} %> | |
72 | - <% end | |
73 | - end %> | |
74 | -</table> | |
75 | - | |
76 | -<br/> | |
77 | -<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_range", :id => @configuration_content.id, :metric_name => @metric.name} %> | |
78 | -<div id="range_form" style="display:none"></div> | |
79 | - | |
80 | -<br/> | |
81 | -<%= render :partial => "metric_codes", :locals => {:metric_configurations => @metric_configurations} %> |
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_compound.html.erb
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +<h2><%= @configuration_content.name %> Configuration</h2> | |
2 | + | |
3 | +<% form_for :metric_configuration, :url => {:action =>"create_compound", :controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
4 | + <%= hidden_field_tag :id, @configuration_content.id %> | |
5 | + <%= f.hidden_field :configuration_id, :value => @configuration_content.configuration_id %> | |
6 | + | |
7 | + <% f.fields_for :metric do |m| %> | |
8 | + <%= m.hidden_field :compound, :value => "true" %> | |
9 | + <%= required labelled_form_field _('Metric Name:'), m.text_field(:name) %> | |
10 | + <%= labelled_form_field _('Description:'), m.text_field(:description) %> | |
11 | + <%= required labelled_form_field _('Script:'), m.text_area(:script, :rows => 5) %> | |
12 | + <%= required labelled_form_field _('Scope:'), m.select(:scope, MezuroPlugin::Helpers::ContentViewerHelper.scope_options) %> | |
13 | + <% end %> | |
14 | + | |
15 | + <%= required labelled_form_field _('Code:'), f.text_field(:code) %> | |
16 | + <%= required labelled_form_field _('Aggregation Form:'), f.select(:aggregation_form, MezuroPlugin::Helpers::ContentViewerHelper.aggregation_options) %> | |
17 | + <%= required labelled_form_field _('Weight:'), f.text_field(:weight) %> | |
18 | + <%= required labelled_form_field _('Reading Group:'), | |
19 | + f.select(:reading_group_id, @reading_group_names_and_ids) %> | |
20 | + | |
21 | + <p> <%= f.submit "Add" %> </p> | |
22 | +<% end %> | |
23 | + | |
24 | +<%= render :partial => "metric_codes", :locals => {:metric_configurations => @metric_configurations} %> | |
25 | + | |
26 | + | ... | ... |
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_compound_metric_configuration.html.erb
... | ... | @@ -1,44 +0,0 @@ |
1 | -<h2><%= @configuration_content.name %> Configuration</h2> | |
2 | - | |
3 | -<% form_for :metric_configuration, :url => {:action =>"create_compound_metric_configuration", | |
4 | -:controller => "mezuro_plugin_metric_configuration"}, :method => :get do |f| %> | |
5 | - <%= hidden_field_tag :id, @configuration_content.id %> | |
6 | - <%= f.hidden_field :configuration_name, :value => @configuration_content.name %> | |
7 | - | |
8 | - <% f.fields_for :metric do |m| %> | |
9 | - <p> | |
10 | - <%= m.label :name, "Name:" %> | |
11 | - <%= m.text_field "name" %> | |
12 | - </p> | |
13 | - <p> | |
14 | - <%= m.label :description, "Description:" %> | |
15 | - <%= m.text_field "description" %> | |
16 | - </p> | |
17 | - <p> | |
18 | - <%= m.label :scope, "Scope:" %> | |
19 | - <%= m.select :scope, [["Class", "CLASS"]] %> | |
20 | - </p> | |
21 | - <p> | |
22 | - <%= m.label :script, "Script:" %> | |
23 | - <%= m.text_area "script", :rows => 5 %> | |
24 | - </p> | |
25 | - <% end %> | |
26 | - <p> | |
27 | - <%= f.label :code, "Code:" %> | |
28 | - <%= f.text_field "code" %> | |
29 | - </p> | |
30 | - <p> | |
31 | - <%= f.label :aggregation_form, "Aggregation Form:" %> | |
32 | - <%= f.select :aggregation_form, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | |
33 | - ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %> | |
34 | - </p> | |
35 | - <p> | |
36 | - <%= f.label :weight, "Weight:" %> | |
37 | - <%= f.text_field :weight %> | |
38 | - </p> | |
39 | - <p> | |
40 | - <%= f.submit "Add" %> | |
41 | - </p> | |
42 | -<% end %> | |
43 | - | |
44 | -<%= render :partial => "metric_codes", :locals => {:metric_configurations => @metric_configurations} %> |
plugins/mezuro/views/mezuro_plugin_metric_configuration/new_native.html.erb
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | <%= labelled_form_field _('Collector Name:'), f.text_field(:base_tool_name, :value => @base_tool_name, :readonly => true) %> |
11 | 11 | |
12 | 12 | <% f.fields_for :metric do |m| %> |
13 | + <%= m.hidden_field :compound, :value => "false" %> | |
13 | 14 | <% @metric.language.each do |language| %> |
14 | 15 | <%= m.hidden_field :language, :multiple => true, :value => language %> |
15 | 16 | <% end %> | ... | ... |