diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-06-18 17:34:38 +0200 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-06-18 17:34:56 +0200 |
commit | 1692dc923faa8f1565d4c37951473ea724647946 (patch) | |
tree | 00ef3a915a4026a572fd44612f53b559ae67f74f | |
parent | f88bef4d748f030663ad0a0c9506607055d48f8c (diff) | |
download | sonarqube-1692dc923faa8f1565d4c37951473ea724647946.tar.gz sonarqube-1692dc923faa8f1565d4c37951473ea724647946.zip |
SONAR-5356 SONAR-5357 Rename custom rule edition button, add delete button on custom rule details
3 files changed, 22 insertions, 3 deletions
diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-custom-rule-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-custom-rule-view.coffee index ac436597ebe..3a8454b78aa 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-custom-rule-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-custom-rule-view.coffee @@ -18,7 +18,7 @@ define [ 'click @ui.delete': 'delete' delete: -> - if confirm('Are you sure ?') + if confirm(t 'are_you_sure') origEl = @$el.html() @$el.html '<i class="spinner"></i>' @@ -28,7 +28,8 @@ define [ data: key: @model.get 'key' .done => - @options.app.showRule @options.templateRule.get 'key' + templateKey = @options.templateKey or @options.templateRule.get 'key' + @options.app.showRule templateKey .fail => @$el.html origEl diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee index c332f92ce4d..8f4504b68fe 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee @@ -4,6 +4,7 @@ define [ 'coding-rules/views/coding-rules-detail-quality-profiles-view' 'coding-rules/views/coding-rules-detail-quality-profile-view' 'coding-rules/views/coding-rules-detail-custom-rules-view' + 'coding-rules/views/coding-rules-detail-custom-rule-view' 'templates/coding-rules' ], ( Backbone @@ -11,6 +12,7 @@ define [ CodingRulesDetailQualityProfilesView CodingRulesDetailQualityProfileView CodingRulesDetailCustomRulesView + CodingRulesDetailCustomRuleView Templates ) -> @@ -46,6 +48,7 @@ define [ changeQualityProfile: '.coding-rules-detail-quality-profile-update' createCustomRule: '#coding-rules-custom-rules-create' changeCustomRule: '#coding-rules-detail-custom-rule-change' + deleteCustomRule: '#coding-rules-detail-custom-rule-delete' events: @@ -62,6 +65,7 @@ define [ 'click @ui.changeQualityProfile': 'changeQualityProfile' 'click @ui.createCustomRule': 'createCustomRule' 'click @ui.changeCustomRule': 'changeCustomRule' + 'click @ui.deleteCustomRule': 'deleteCustomRule' initialize: (options) -> @@ -254,6 +258,19 @@ define [ @options.app.codingRulesCustomRuleCreationView.show() + deleteCustomRule: -> + if confirm(t 'are_you_sure') + jQuery.ajax + type: 'POST' + url: "#{baseUrl}/api/rules/delete" + data: + key: @model.get 'key' + .done => + @options.app.fetchFirstPage() + .fail => + @options.app.showRule @model.get('key') + + serializeData: -> contextQualityProfile = @options.app.getQualityProfile() repoKey = @model.get 'repo' diff --git a/sonar-server/src/main/hbs/coding-rules/coding-rules-detail.hbs b/sonar-server/src/main/hbs/coding-rules/coding-rules-detail.hbs index 3af575f8f19..5d2829b2f18 100644 --- a/sonar-server/src/main/hbs/coding-rules/coding-rules-detail.hbs +++ b/sonar-server/src/main/hbs/coding-rules/coding-rules-detail.hbs @@ -54,7 +54,8 @@ {{#if canWrite}} <div class="coding-rules-detail-description"> <div class="button-group"> - <button id="coding-rules-detail-custom-rule-change">{{t 'change_verb'}}</button> + <button id="coding-rules-detail-custom-rule-change">{{t 'edit'}}</button> + <button id="coding-rules-detail-custom-rule-delete" class="button-red">{{t 'delete'}}</button> </div> </div> {{/if}} |