From: Jean-Baptiste Lievremont Date: Wed, 18 Jun 2014 15:34:38 +0000 (+0200) Subject: SONAR-5356 SONAR-5357 Rename custom rule edition button, add delete button on custom... X-Git-Tag: 4.4-RC1~342 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1692dc923faa8f1565d4c37951473ea724647946;p=sonarqube.git SONAR-5356 SONAR-5357 Rename custom rule edition button, add delete button on custom rule details --- 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 '' @@ -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}}
- + +
{{/if}}