From a45410ce72caac576647d8005bd97fed53943aae Mon Sep 17 00:00:00 2001 From: João M. M. da Silva + Paulo Meirelles Date: Tue, 28 Aug 2012 16:30:43 -0300 Subject: [PATCH] [Mezuro] refactored charts call to use just one click --- plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb | 2 ++ plugins/mezuro/public/javascripts/project_content.js | 8 ++++---- plugins/mezuro/views/content_viewer/_module_result.rhtml | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------- 3 files changed, 56 insertions(+), 62 deletions(-) diff --git a/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb b/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb index 9062b24..84a140a 100644 --- a/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb +++ b/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb @@ -41,6 +41,8 @@ class MezuroPluginProfileController < ProfileController def module_result @content = profile.articles.find(params[:id]) @module_result = @content.module_result(params) + @module = @module_result.module + @module_label = "#{@module.name} (#{@module.granularity})" if project_content_has_errors? redirect_to_error_page(@content.errors[:base]) else diff --git a/plugins/mezuro/public/javascripts/project_content.js b/plugins/mezuro/public/javascripts/project_content.js index f40868d..1b87c70 100644 --- a/plugins/mezuro/public/javascripts/project_content.js +++ b/plugins/mezuro/public/javascripts/project_content.js @@ -2,7 +2,6 @@ var processingTree = false; var metricName; jQuery(function (){ jQuery('.source-tree-link').live("click", reloadModule); - jQuery('[data-show]').live("click", toggle_mezuro); jQuery('[show-metric-history]').live("click", display_metric_history); jQuery('[show-grade-history]').live("click", display_grade_history); jQuery('#project_date_submit').live("click", reloadProjectWithDate); @@ -16,7 +15,8 @@ function showProjectContent() { function display_metric_history() { var module_name = jQuery(this).attr('data-module-name'); - var metric_name = jQuery(this).attr('data-metric-name'); + var metric_name = jQuery(this).attr('show-metric-history'); + toggle_mezuro("." + metric_name); metricName = metric_name; callAction('module_metrics_history', {module_name: module_name, metric_name: metric_name}, show_metrics); return false; @@ -24,6 +24,7 @@ function display_metric_history() { function display_grade_history() { var module_name = jQuery(this).attr('data-module-name'); + toggle_mezuro("#historical-grade"); callAction('module_grade_history', {module_name: module_name}, show_grades); return false; } @@ -36,8 +37,7 @@ function show_grades(content) { jQuery('#historical-grade').html(content); } -function toggle_mezuro(){ - var element = jQuery(this).attr('data-show'); +function toggle_mezuro(element){ jQuery(element).toggle(); return false; } diff --git a/plugins/mezuro/views/content_viewer/_module_result.rhtml b/plugins/mezuro/views/content_viewer/_module_result.rhtml index 3684b19..bb068f4 100644 --- a/plugins/mezuro/views/content_viewer/_module_result.rhtml +++ b/plugins/mezuro/views/content_viewer/_module_result.rhtml @@ -1,60 +1,52 @@ -<% unless @content.errors[:base].nil? %> - <%= @content.errors[:base] %> -<% else %> - <% the_module = @module_result.module %> - <% module_label = "#{the_module.name} (#{the_module.granularity})" %> +
<%= _('Metric results for: ') + @module_label %>
-
<%= _('Metric results for: ') + module_label %>
- -
-
- - - - - - - - - - - <% @module_result.metric_results.each do |metric_result| %> - <% range = metric_result.range %> - <% if !range.nil? %> - - - - - - - - - - - <% end %> +
+
+
MetricValueWeightThreshold
<%= metric_result.metric.name %><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %><%= metric_result.weight %><%= range.label %>
+ + + + + + + + + + <% @module_result.metric_results.each do |metric_result| %> + <% range = metric_result.range %> + <% if !range.nil? %> + + + + + + + + + + <% end %> - - - - - - - -
MetricValueWeightThreshold
<%= metric_result.metric.name %><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %><%= metric_result.weight %><%= range.label %>
-
-
- - - <%= _('Grade:') %> - <%= "%.02f" % @module_result.grade %> - - -
-
-<% end %> + <% end %> + + + + + + + + + + <%= _('Grade:') %> + <%= "%.02f" % @module_result.grade %> + + + + + + + -- libgit2 0.21.2