diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-09-15 16:19:56 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-09-15 16:19:56 +0200 |
commit | 12c4bbe39f88c1b34ffb0069de5f8209e561a391 (patch) | |
tree | a256c7646b30df582972c119bbae55aa4a8d1765 | |
parent | 5356f507f1701bfd26d2370766b4157c47bde790 (diff) | |
download | sonarqube-12c4bbe39f88c1b34ffb0069de5f8209e561a391.tar.gz sonarqube-12c4bbe39f88c1b34ffb0069de5f8209e561a391.zip |
SONAR-6284 force project widgets displayed on global dashboards to select a project
-rw-r--r-- | server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb | 50 | ||||
-rw-r--r-- | sonar-core/src/main/resources/org/sonar/l10n/core.properties | 1 |
2 files changed, 32 insertions, 19 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb index ae419530933..a7492f091c9 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/_widget_properties.html.erb @@ -1,16 +1,4 @@ -<form onsubmit="$j.ajax({ - url: '<%= ApplicationController.root_context-%>/dashboard/save_widget?wid=<%=widget.id-%>&id=<%= params[:id] -%>', - type: 'post', - data: $j(this).serialize(), - error: function(request) - { - $j('#error<%=widget.id-%>').text(request.responseText); - $j('#error<%=widget.id-%>').show(); - } - }); - return false;" - method="post" - action="<%= ApplicationController.root_context-%>/dashboard/save_widget?wid=<%=widget.id-%>"> +<form id="configure-widget-<%= widget.id -%>" method="post" action="<%= ApplicationController.root_context -%>/dashboard/save_widget?wid=<%= widget.id -%>"> <div id="error<%= widget.id -%>" class="error" style="display: none"></div> <table class="table width100"> <tbody> @@ -20,12 +8,12 @@ <td class="form-key-cell"><%= message('widget.resource_id') %> <em class="mandatory">*</em></td> <td class="form-val-cell" id="row_resource"> <%= resource_select_tag 'resource_id', { - :resource_type_property => 'supportsGlobalDashboards', - :selected_resource => widget.resource, - :width => '250px', - :html_id => "widget-#{widget.id}-select-prj-#{widget.key.parameterize}", - :html_class => "widget-select-prj-#{widget.key.parameterize}" - } -%> + :resource_type_property => 'supportsGlobalDashboards', + :selected_resource => widget.resource, + :width => '250px', + :html_id => "widget-#{widget.id}-select-prj-#{widget.key.parameterize}", + :html_class => "widget-select-prj-#{widget.key.parameterize}" + } -%> </td> </tr> <% end %> @@ -65,3 +53,27 @@ </table> <%= hidden_field_tag "widgetid", "", :class => "widgetid" %> </form> + +<script> + (function ($) { + $('#configure-widget-<%= widget.id -%>').on('submit', function (e) { + e.preventDefault(); + var form = $(e.currentTarget); + var resourceInput = form.find('input[name="resource_id"]'); + if (resourceInput.length && !resourceInput.val()) { + $('#error<%= widget.id -%>').text('<%= escape_javascript message('widget.select_project') -%>'); + $('#error<%= widget.id -%>').show(); + } else { + $.ajax({ + url: baseUrl + '/dashboard/save_widget?wid=<%= widget.id -%>&id=<%= params[:id] -%>', + type: 'POST', + data: form.serialize(), + error: function (request) { + $('#error<%= widget.id -%>').text(request.responseText); + $('#error<%= widget.id -%>').show(); + } + }); + } + }); + })(window.jQuery); +</script> diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 7d1353c4d7f..f064cda2cb8 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1121,6 +1121,7 @@ widgets.more=More widget.error_occurred_please_read_logs=An error occurred while trying to display the widget "{0}". Please contact the administrator. widget.unsupported_browser_warning=Your browser is out of date and does not support this widget. widget.as_calculated_on_x=As calculated on {0} +widget.select_project=Please select a project widget.alerts.name=Quality Gate widget.alerts.description=Displays the project's quality gate status. |