From 37a018029bb7382f293d20d81e03a2d5e716dfcd Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 4 Jun 2015 14:20:47 +0200 Subject: [PATCH] SONAR-6595 show error message when activate a rule with a parameter is set to an erroneous value --- .../rule/profile-activation-view.js | 32 +++++++++++-------- .../rule/coding-rules-profile-activation.hbs | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js index 5381c6299bc..e12c4730469 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js @@ -18,30 +18,32 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ define([ - 'components/common/modals', + 'components/common/modal-form', '../templates' -], function (Modal) { +], function (ModalForm) { var $ = jQuery; - return Modal.extend({ + return ModalForm.extend({ template: Templates['coding-rules-profile-activation'], - ui: { - qualityProfileSelect: '#coding-rules-quality-profile-activation-select', - qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity', - qualityProfileActivate: '#coding-rules-quality-profile-activation-activate', - qualityProfileParameters: '[name]' + ui: function () { + return _.extend(this._super(), { + qualityProfileSelect: '#coding-rules-quality-profile-activation-select', + qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity', + qualityProfileActivate: '#coding-rules-quality-profile-activation-activate', + qualityProfileParameters: '[name]' + }); }, events: function () { - return _.extend(Modal.prototype.events.apply(this, arguments), { + return _.extend(this._super(), { 'click @ui.qualityProfileActivate': 'activate' }); }, onRender: function () { - Modal.prototype.onRender.apply(this, arguments); + this._super(); this.ui.qualityProfileSelect.select2({ width: '250px', @@ -93,7 +95,7 @@ define([ var severity = this.ui.qualityProfileSeverity.val(), ruleKey = this.options.rule.get('key'); - this.close(); + this.disableForm(); return jQuery.ajax({ type: 'POST', @@ -109,9 +111,11 @@ define([ 400: null } }).done(function () { + that.close(); that.trigger('profileActivated', severity, params); - }).fail(function () { - that.trigger('profileActivationFailed'); + }).fail(function (jqXHR) { + that.enableForm(); + that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); }); }, @@ -142,7 +146,7 @@ define([ var availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang')); - return _.extend(Modal.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { change: this.model && this.model.has('severity'), params: params, qualityProfiles: availableProfiles, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs index 2b47036fd89..e7a7164d4c4 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs @@ -8,7 +8,7 @@