From fc86d6794049a0f498dc0b85b9350198b4ac7444 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Fri, 13 Jul 2012 15:58:19 +0200 Subject: [PATCH] SONAR-3628 Possibility to customise the title of global widget --- .../org/sonar/plugins/core/widgets/filter.html.erb | 8 ++++++-- .../main/webapp/WEB-INF/app/helpers/dashboard_helper.rb | 7 +++++++ .../WEB-INF/app/views/dashboard/_widget_title.html.erb | 8 ++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/filter.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/filter.html.erb index 76bc1efe49b..5887e4999bf 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/filter.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/filter.html.erb @@ -1,6 +1,10 @@ <% - @filter=::Filter.find(:first, :conditions => {:kee => widget_properties['filter']}) - @filter_context=Filters.execute(@filter, self, params) unless @filter.ajax_loading? + @filter=::Filter.find(:first, :conditions => {:kee => widget_properties['filter']}) + @filter_context=Filters.execute(@filter, self, params) unless @filter.ajax_loading? + + name=@filter.name + period=period_names[@filter.period_index - 1] if @filter.period_index + @widget_title=[h(name), period].compact.join(' - ') %> <%= render :partial => "filters/#{@filter.default_view}", :locals => {:edit_mode => false, :widget => widget} %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb index 803c7f16fb9..fdbe448c5fc 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb @@ -117,6 +117,13 @@ module DashboardHelper @project=@backup_project @snapshot=@backup_snapshot @dashboard_configuration=@backup_dashboard_configuration + @widget_title=nil + end + + def widget_title(widget) + resource_name=h(@resource.name) if @resource && @dashboard.global && !widget.java_definition.global + + [resource_name, @widget_title].compact.join(' - ') end def widget_body(widget) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_title.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_title.html.erb index f9b4a7bcd5a..0c9fb7ae468 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_title.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget_title.html.erb @@ -1,7 +1,3 @@ -<% if widget.properties_as_hash['filter'] and @filter %> -
- <%= h @filter.name -%><% if @filter.period_index %> - <%= period_names[@filter.period_index-1] -%><% end %> -
-<% elsif @dashboard.global and @resource and !widget.java_definition.global %> -
<%= h @resource.name -%>
+<% unless widget_title(widget).blank? %> +
<%= widget_title(widget) -%>
<% end %> -- 2.39.5