'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>'
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
'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
CodingRulesDetailQualityProfilesView
CodingRulesDetailQualityProfileView
CodingRulesDetailCustomRulesView
+ CodingRulesDetailCustomRuleView
Templates
) ->
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:
'click @ui.changeQualityProfile': 'changeQualityProfile'
'click @ui.createCustomRule': 'createCustomRule'
'click @ui.changeCustomRule': 'changeCustomRule'
+ 'click @ui.deleteCustomRule': 'deleteCustomRule'
initialize: (options) ->
@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'
{{#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}}