diff --git a/plugins/mezuro/controllers/myprofile/mezuro_plugin_base_tool_controller.rb b/plugins/mezuro/controllers/myprofile/mezuro_plugin_base_tool_controller.rb index 5b6632c..ff0871b 100644 --- a/plugins/mezuro/controllers/myprofile/mezuro_plugin_base_tool_controller.rb +++ b/plugins/mezuro/controllers/myprofile/mezuro_plugin_base_tool_controller.rb @@ -2,16 +2,9 @@ class MezuroPluginBaseToolController < MezuroPluginMyprofileController append_view_path File.join(File.dirname(__FILE__) + '/../../views') - def choose_base_tool - @configuration_content = profile.articles.find(params[:id]) - @base_tools = Kalibro::BaseTool.all_names - end - def choose_metric @configuration_content = profile.articles.find(params[:id]) - @base_tool = params[:base_tool] - base_tool = Kalibro::BaseTool.find_by_name(@base_tool) - @supported_metrics = base_tool.nil? ? [] : base_tool.supported_metrics + @base_tools = Kalibro::BaseTool.all end end diff --git a/plugins/mezuro/lib/kalibro/base_tool.rb b/plugins/mezuro/lib/kalibro/base_tool.rb index a57e16e..c24a54c 100644 --- a/plugins/mezuro/lib/kalibro/base_tool.rb +++ b/plugins/mezuro/lib/kalibro/base_tool.rb @@ -10,6 +10,11 @@ class Kalibro::BaseTool < Kalibro::Model new request("BaseTool", :get_base_tool, {:base_tool_name => base_tool_name})[:base_tool] end + def self.all + basetools = all_names + basetools.map{ |name| find_by_name(name) } + end + def supported_metric=(value) @supported_metric = Kalibro::NativeMetric.to_objects_array value end diff --git a/plugins/mezuro/test/functional/myprofile/mezuro_plugin_base_tool_controller_test.rb b/plugins/mezuro/test/functional/myprofile/mezuro_plugin_base_tool_controller_test.rb index 65b75eb..886a763 100644 --- a/plugins/mezuro/test/functional/myprofile/mezuro_plugin_base_tool_controller_test.rb +++ b/plugins/mezuro/test/functional/myprofile/mezuro_plugin_base_tool_controller_test.rb @@ -22,20 +22,12 @@ class MezuroPluginBaseToolControllerTest < ActionController::TestCase @content.save end - should 'test choose base tool' do - Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool_names).returns({:base_tool_name => @base_tool.name}) - get :choose_base_tool, :profile => @profile.identifier, :id => @content.id - assert_equal [@base_tool.name], assigns(:base_tools) - assert_equal @content, assigns(:configuration_content) - assert_response 200 - end - should 'test choose metric' do + Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool_names).returns({:base_tool_name => @base_tool.name}) Kalibro::BaseTool.expects(:request).with("BaseTool", :get_base_tool, {:base_tool_name => @base_tool.name}).returns({:base_tool => @base_tool_hash}) - get :choose_metric, :profile => @profile.identifier, :id => @content.id, :base_tool => @base_tool.name + get :choose_metric, :profile => @profile.identifier, :id => @content.id + assert_equal @base_tool.name, assigns(:base_tools).first.name assert_equal @content, assigns(:configuration_content) - assert_equal @base_tool.name, assigns(:base_tool) - assert_equal @base_tool.supported_metric[0].name, assigns(:supported_metrics)[0].name assert_response 200 end diff --git a/plugins/mezuro/views/content_viewer/show_configuration.rhtml b/plugins/mezuro/views/content_viewer/show_configuration.rhtml index b57bb5a..5013dbd 100644 --- a/plugins/mezuro/views/content_viewer/show_configuration.rhtml +++ b/plugins/mezuro/views/content_viewer/show_configuration.rhtml @@ -1,9 +1,14 @@ <% @configuration_content = @page @kalibro_configuration = @page.kalibro_configuration %> +<% owner = (not user.nil?) && user.id == @profile.id %> + <% unless @page.errors[:base].nil? %> <% if @page.errors[:base] =~ /There is no configuration named/ %>

Warning:

-

This Configuration doesn't exist on the Web Service. Do you want to <%= link_to 'delete', :action => 'destroy', :controller => 'cms', :profile => @page.profile.identifier, :id => @page.id %> or <%= link_to 'save it again', :action => 'edit', :controller => 'cms', :profile => @page.profile.identifier, :id => @page.id %>?

+

This Configuration doesn't exist on the Web Service.

+ <% if owner %> +

Do you want to <%= link_to 'delete', :action => 'destroy', :controller => 'cms', :profile => @page.profile.identifier, :id => @page.id %> or <%= link_to 'save it again', :action => 'edit', :controller => 'cms', :profile => @page.profile.identifier, :id => @page.id %>?

+ <% end %> <% else %> <%= @page.errors[:base] %> <% end %> @@ -22,42 +27,44 @@
- <%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Metric", :controller => "mezuro_plugin_base_tool", + <% if owner %> + <%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Metric", :controller => "mezuro_plugin_base_tool", :profile => @page.profile.identifier, - :action => "choose_base_tool", + :action => "choose_metric", :id => @configuration_content.id %>
+ <% end %> - <% @kalibro_configuration.metric_configurations.each do |metric_configuration| %> - <% if metric_configuration.metric.instance_of? Kalibro::NativeMetric %> + - <% else %> + - <% end %> - - + <% end %> <% end %>
Metric Name
Collector Name
Metric Code
+
<%= metric_configuration.metric.name %><%= link_to metric_configuration.metric.name, :controller => "mezuro_plugin_metric_configuration", :action => "edit_metric_configuration", + :metric_name => metric_configuration.metric.name, :id => @configuration_content.id, + :profile => @page.profile.identifier %> <%= metric_configuration.metric.origin %> <%= metric_configuration.code %><%= link_to "Edit", :controller => "mezuro_plugin_metric_configuration", :action => "edit_metric_configuration", - :metric_name => metric_configuration.metric.name, :id => @configuration_content.id, - :profile => @page.profile.identifier %><%= link_to metric_configuration.metric.name, :controller => "mezuro_plugin_metric_configuration", + :action => "edit_compound_metric_configuration", :metric_name => metric_configuration.metric.name, + :id => @configuration_content.id, :profile => @page.profile.identifier %> Compound Metric <%= metric_configuration.code %><%= link_to "Edit", :controller => "mezuro_plugin_metric_configuration", - :action => "edit_compound_metric_configuration", :metric_name => metric_configuration.metric.name, - :id => @configuration_content.id, :profile => @page.profile.identifier %><%= link_to "Remove", :controller => "mezuro_plugin_metric_configuration", :action => "remove_metric_configuration", + <% if owner %> + <%= link_to "Remove", :controller => "mezuro_plugin_metric_configuration", :action => "remove_metric_configuration", :metric_name => metric_configuration.metric.name, :id => @configuration_content.id, :profile => @page.profile.identifier %>
diff --git a/plugins/mezuro/views/mezuro_plugin_base_tool/choose_base_tool.html.erb b/plugins/mezuro/views/mezuro_plugin_base_tool/choose_base_tool.html.erb deleted file mode 100644 index 6b2f540..0000000 --- a/plugins/mezuro/views/mezuro_plugin_base_tool/choose_base_tool.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -

<%= @configuration_content.name%> Configuration

- -<%= link_to "New Compound Metric", :controller => "mezuro_plugin_metric_configuration", :action => "new_compound_metric_configuration", - :id => @configuration_content.id %> - -
Base Tools:
- - <% @base_tools.each do |base_tool| %> - - - - <% end %> -
- <%= link_to base_tool, :controller => "mezuro_plugin_base_tool", :action => "choose_metric", :base_tool => base_tool, - :id => @configuration_content.id %> -
diff --git a/plugins/mezuro/views/mezuro_plugin_base_tool/choose_metric.html.erb b/plugins/mezuro/views/mezuro_plugin_base_tool/choose_metric.html.erb index 879cf5f..bddab69 100644 --- a/plugins/mezuro/views/mezuro_plugin_base_tool/choose_metric.html.erb +++ b/plugins/mezuro/views/mezuro_plugin_base_tool/choose_metric.html.erb @@ -1,18 +1,18 @@ -

<%= @configuration_content.name %> Configuration

+

<%= @configuration_content.name%> Configuration

- - -
Metric Collector: <%= @base_tool %>
- - -
Choose a metric to add:
- - <% @supported_metrics.each do |metric| %> - - - - <% end %> -
- <%= link_to metric.name, :controller => "mezuro_plugin_metric_configuration", :action => "new_metric_configuration", - :metric_name => metric.name, :base_tool => @base_tool, :id => @configuration_content.id %> -
+<%= link_to "New Compound Metric", :controller => "mezuro_plugin_metric_configuration", :action => "new_compound_metric_configuration", + :id => @configuration_content.id %> + +
Base Tools:
+<% @base_tools.each do |base_tool| %> +

<%= link_to base_tool.name, "#", :onclick => "jQuery(\"\##{base_tool.name}\").toggle();"%>

+
+ + +<% end %> -- libgit2 0.21.2