]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5356 SONAR-5357 Rename custom rule edition button, add delete button on custom...
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Wed, 18 Jun 2014 15:34:38 +0000 (17:34 +0200)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Wed, 18 Jun 2014 15:34:56 +0000 (17:34 +0200)
sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-custom-rule-view.coffee
sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee
sonar-server/src/main/hbs/coding-rules/coding-rules-detail.hbs

index ac436597ebe5dfb141c0964913d36727491a55c0..3a8454b78aae9e765802082f92770bf6d13713aa 100644 (file)
@@ -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
 
index c332f92ce4d78926f3516d39aab480fb8059bb31..8f4504b68fe22924d74c1f91361beb0d15a9f222 100644 (file)
@@ -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'
index 3af575f8f19883d49bcc4aec30d7444d0752f860..5d2829b2f18cdbe425d607d55d50eb5e602636b9 100644 (file)
@@ -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}}