Commit a45410ce72caac576647d8005bd97fed53943aae
Committed by
Paulo Meireles
1 parent
15c90f52
Exists in
master
and in
29 other branches
[Mezuro] refactored charts call to use just one click
Showing
3 changed files
with
56 additions
and
62 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... | ... | @@ -41,6 +41,8 @@ class MezuroPluginProfileController < ProfileController |
41 | 41 | def module_result |
42 | 42 | @content = profile.articles.find(params[:id]) |
43 | 43 | @module_result = @content.module_result(params) |
44 | + @module = @module_result.module | |
45 | + @module_label = "#{@module.name} (#{@module.granularity})" | |
44 | 46 | if project_content_has_errors? |
45 | 47 | redirect_to_error_page(@content.errors[:base]) |
46 | 48 | else | ... | ... |
plugins/mezuro/public/javascripts/project_content.js
... | ... | @@ -2,7 +2,6 @@ var processingTree = false; |
2 | 2 | var metricName; |
3 | 3 | jQuery(function (){ |
4 | 4 | jQuery('.source-tree-link').live("click", reloadModule); |
5 | - jQuery('[data-show]').live("click", toggle_mezuro); | |
6 | 5 | jQuery('[show-metric-history]').live("click", display_metric_history); |
7 | 6 | jQuery('[show-grade-history]').live("click", display_grade_history); |
8 | 7 | jQuery('#project_date_submit').live("click", reloadProjectWithDate); |
... | ... | @@ -16,7 +15,8 @@ function showProjectContent() { |
16 | 15 | |
17 | 16 | function display_metric_history() { |
18 | 17 | var module_name = jQuery(this).attr('data-module-name'); |
19 | - var metric_name = jQuery(this).attr('data-metric-name'); | |
18 | + var metric_name = jQuery(this).attr('show-metric-history'); | |
19 | + toggle_mezuro("." + metric_name); | |
20 | 20 | metricName = metric_name; |
21 | 21 | callAction('module_metrics_history', {module_name: module_name, metric_name: metric_name}, show_metrics); |
22 | 22 | return false; |
... | ... | @@ -24,6 +24,7 @@ function display_metric_history() { |
24 | 24 | |
25 | 25 | function display_grade_history() { |
26 | 26 | var module_name = jQuery(this).attr('data-module-name'); |
27 | + toggle_mezuro("#historical-grade"); | |
27 | 28 | callAction('module_grade_history', {module_name: module_name}, show_grades); |
28 | 29 | return false; |
29 | 30 | } |
... | ... | @@ -36,8 +37,7 @@ function show_grades(content) { |
36 | 37 | jQuery('#historical-grade').html(content); |
37 | 38 | } |
38 | 39 | |
39 | -function toggle_mezuro(){ | |
40 | - var element = jQuery(this).attr('data-show'); | |
40 | +function toggle_mezuro(element){ | |
41 | 41 | jQuery(element).toggle(); |
42 | 42 | return false; |
43 | 43 | } | ... | ... |
plugins/mezuro/views/content_viewer/_module_result.rhtml
1 | -<% unless @content.errors[:base].nil? %> | |
2 | - <%= @content.errors[:base] %> | |
3 | -<% else %> | |
4 | - <% the_module = @module_result.module %> | |
5 | - <% module_label = "#{the_module.name} (#{the_module.granularity})" %> | |
1 | +<h5><%= _('Metric results for: ') + @module_label %> </h5> | |
6 | 2 | |
7 | - <h5><%= _('Metric results for: ') + module_label %> </h5> | |
8 | - | |
9 | - <hr/> | |
10 | - <div class="zoomable-image"> | |
11 | - <table> | |
12 | - <thead> | |
13 | - <tr> | |
14 | - <th>Metric</th> | |
15 | - <th>Value</th> | |
16 | - <th>Weight</th> | |
17 | - <th>Threshold</th> | |
18 | - </tr> | |
19 | - </thead> | |
20 | - <tbody> | |
21 | - <% @module_result.metric_results.each do |metric_result| %> | |
22 | - <% range = metric_result.range %> | |
23 | - <% if !range.nil? %> | |
24 | - <tr> | |
25 | - <td><a href="#" data-show=".<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>"><%= metric_result.metric.name %></a></td> | |
26 | - <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> | |
27 | - <td><%= metric_result.weight %></td> | |
28 | - <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> | |
29 | - </tr> | |
30 | - <tr class="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" style="display: none;"> | |
31 | - <td colspan="3"> | |
32 | - <div id='historical-<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>'> | |
33 | - <a href="#" show-metric-history="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" data-module-name="<%= the_module.name %>" data-metric-name="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>"> <p style="text-indent: 3em;"> Get Historical Values </p> </a> | |
34 | - </div> | |
35 | - </td> | |
36 | - <td align="right"> | |
37 | - <%= range.comments.nil? ? '' : range.comments %> | |
38 | - </td> | |
39 | - </tr> | |
40 | - <% end %> | |
3 | +<hr/> | |
4 | +<div class="zoomable-image"> | |
5 | +<table> | |
6 | + <thead> | |
7 | + <tr> | |
8 | + <th>Metric</th> | |
9 | + <th>Value</th> | |
10 | + <th>Weight</th> | |
11 | + <th>Threshold</th> | |
12 | + </tr> | |
13 | + </thead> | |
14 | + <tbody> | |
15 | + <% @module_result.metric_results.each do |metric_result| %> | |
16 | + <% range = metric_result.range %> | |
17 | + <% if !range.nil? %> | |
18 | + <tr> | |
19 | + <td><a href="#" show-metric-history="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" data-module-name="<%= @module.name %>"><%= metric_result.metric.name %></a></td> | |
20 | + <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> | |
21 | + <td><%= metric_result.weight %></td> | |
22 | + <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> | |
23 | + </tr> | |
24 | + <tr class="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" style="display: none;"> | |
25 | + <td colspan="3"> | |
26 | + <div id='historical-<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>'> | |
27 | + </div> | |
28 | + </td> | |
29 | + <td align="right"> | |
30 | + <%= range.comments.nil? ? '' : range.comments %> | |
31 | + </td> | |
32 | + </tr> | |
41 | 33 | <% end %> |
42 | - </tbody> | |
43 | - <tfoot> | |
44 | - <tr> | |
45 | - <td colspan = "3"> | |
46 | - <div id='historical-grade'></div> | |
47 | - </td> | |
48 | - <td align = "right"> | |
49 | - <a href="#" show-grade-history="<%= @module_result.module.name %>" data-module-name="<%= the_module.name%>" > | |
50 | - <strong> | |
51 | - <%= _('Grade:') %> | |
52 | - <%= "%.02f" % @module_result.grade %> | |
53 | - </strong> | |
54 | - </a> | |
55 | - </td> | |
56 | - </tr> | |
57 | - </tfoot> | |
58 | - </table> | |
59 | - </div> | |
60 | -<% end %> | |
34 | + <% end %> | |
35 | + </tbody> | |
36 | + <tfoot> | |
37 | + <tr> | |
38 | + <td colspan = "3"> | |
39 | + <div id='historical-grade' style="display: none;"></div> | |
40 | + </td> | |
41 | + <td align = "right"> | |
42 | + <a href="#" show-grade-history="<%= @module_result.module.name %>" data-module-name="<%= @module.name%>" > | |
43 | + <strong> | |
44 | + <%= _('Grade:') %> | |
45 | + <%= "%.02f" % @module_result.grade %> | |
46 | + </strong> | |
47 | + </a> | |
48 | + </td> | |
49 | + </tr> | |
50 | + </tfoot> | |
51 | +</table> | |
52 | +</div> | ... | ... |