From 7ae3dffcb33ac3f25e1291047b2b7d56ae8267e8 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 18 Feb 2015 16:09:09 +0100 Subject: [PATCH] fix edition of custom rules --- .../hbs/coding-rules/rule/coding-rules-custom-rule.hbs | 2 +- .../src/main/js/coding-rules/rule-details-view.js | 10 ++++++++++ .../js/coding-rules/rule/custom-rule-creation-view.js | 8 ++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/server/sonar-web/src/main/hbs/coding-rules/rule/coding-rules-custom-rule.hbs b/server/sonar-web/src/main/hbs/coding-rules/rule/coding-rules-custom-rule.hbs index 94f72b03f35..b5371ee37f3 100644 --- a/server/sonar-web/src/main/hbs/coding-rules/rule/coding-rules-custom-rule.hbs +++ b/server/sonar-web/src/main/hbs/coding-rules/rule/coding-rules-custom-rule.hbs @@ -1,5 +1,5 @@ - {{name}} + {{name}} diff --git a/server/sonar-web/src/main/js/coding-rules/rule-details-view.js b/server/sonar-web/src/main/js/coding-rules/rule-details-view.js index 30dfcc6c4e2..7e4cd25237f 100644 --- a/server/sonar-web/src/main/js/coding-rules/rule-details-view.js +++ b/server/sonar-web/src/main/js/coding-rules/rule-details-view.js @@ -6,6 +6,7 @@ define([ 'coding-rules/rule/rule-profiles-view', 'coding-rules/rule/custom-rules-view', 'coding-rules/rule/manual-rule-creation-view', + 'coding-rules/rule/custom-rule-creation-view', 'coding-rules/rule/rule-issues-view', 'templates/coding-rules' ], @@ -16,6 +17,7 @@ define([ ProfilesView, CustomRulesView, ManualRuleCreationView, + CustomRuleCreationView, IssuesView) { var $ = jQuery; @@ -35,6 +37,7 @@ define([ events: { 'click .js-edit-manual': 'editManualRule', + 'click .js-edit-custom': 'editCustomRule', 'click .js-delete': 'deleteRule' }, @@ -132,6 +135,13 @@ define([ }).render(); }, + editCustomRule: function () { + new CustomRuleCreationView({ + app: this.options.app, + model: this.model + }).render(); + }, + deleteRule: function () { var that = this, ruleType = this.model.has('templateKey') ? 'custom' : 'manual'; diff --git a/server/sonar-web/src/main/js/coding-rules/rule/custom-rule-creation-view.js b/server/sonar-web/src/main/js/coding-rules/rule/custom-rule-creation-view.js index efa3a520e14..7166ca8f205 100644 --- a/server/sonar-web/src/main/js/coding-rules/rule/custom-rule-creation-view.js +++ b/server/sonar-web/src/main/js/coding-rules/rule/custom-rule-creation-view.js @@ -139,7 +139,11 @@ define([ var that = this, url = baseUrl + '/api/rules/' + action; return $.post(url, options).done(function () { - that.options.app.controller.showDetails(that.options.templateRule); + if (that.options.templateRule) { + that.options.app.controller.showDetails(that.options.templateRule); + } else { + that.options.app.controller.showDetails(that.model); + } that.close(); }).fail(function (jqXHR) { if (jqXHR.status === 409) { @@ -158,7 +162,7 @@ define([ params = this.options.templateRule.get('params'); } else if (this.model && this.model.has('params')) { params = this.model.get('params').map(function (p) { - _.extend(p, { value: p.defaultValue }); + return _.extend(p, { value: p.defaultValue }); }); } -- 2.39.5