doAction: (e) ->
action = jQuery(e.currentTarget).data 'action'
param = jQuery(e.currentTarget).data 'param'
- unless param
- @options.app.codingRulesBulkChangeView.show action
- else
- query = @options.app.getQuery()
- _.extend query,
- profile_key: param
- wsAction: action
- @options.app.codingRulesBulkChangeView.bulkChange query
+ @options.app.codingRulesBulkChangeView.show action, param
onRender: ->
escapeMarkup: (m) -> m
- show: (action) ->
+ show: (action, param = null) ->
@action = action
+ @profile = param
@render()
@$el.dialog 'open'
if @action == 'activate' || @action == 'deactivate'
_.extend query,
wsAction: @action
- profile_key: @$('#coding-rules-bulk-change-profile').val()
+ profile_key: @$('#coding-rules-bulk-change-profile').val() or @profile
if @action == 'change-severity'
_.extend query,
wsAction: 'activate'
- profile_key: @options.app.getQualityProfile()
+ profile_key: @profile
activation_severity: @$('#coding-rules-bulk-change-severity').val()
query
bulkChange: (query) ->
wsAction = query.wsAction
query = _.omit(query, 'wsAction')
+
+ origFooter = @$('.modal-foot').html()
+ @$('.modal-foot').html '<i class="spinner"></i>'
+
jQuery.ajax
type: 'POST'
url: "#{baseUrl}/api/qualityprofiles/#{wsAction}_rules"
data: query
.done =>
@options.app.fetchFirstPage(true)
+ @hide()
+ .fail =>
+ @$('.modal-foot').html origFooter
onSubmit: (e) ->
e.preventDefault()
- @bulkChange(@prepareQuery()).done => @hide()
+ @bulkChange(@prepareQuery())
getAvailableQualityProfiles: ->
paging: @options.app.codingRules.paging
qualityProfiles: @options.app.qualityProfiles
- qualityProfile: @options.app.getQualityProfile()
+ qualityProfile: @profile
qualityProfileName: @options.app.qualityProfileFilter.view.renderValue()
availableQualityProfiles: @getAvailableQualityProfiles()
profileKey = @model.get('key')
severity = @ui.qualityProfileSeverity.val()
+ origFooter = @$('.modal-foot').html()
@$('.modal-foot').html '<i class="spinner"></i>'
+
ruleKey = @rule.get('key')
jQuery.ajax
type: 'POST'
.done =>
@options.app.showRule ruleKey
@hide()
+ .fail =>
+ @$('.modal-foot').html origFooter
onRender: ->
{{! severity }}
{{#eq activation 'true'}}
- <a class="coding-rules-bulk-change-dropdown-link" data-action="change-severity">
+ <a class="coding-rules-bulk-change-dropdown-link" data-action="change-severity" data-param="{{qualityProfile}}">
{{t 'coding_rules.change_severity_in'}} <strong>{{qualityProfileName}}</strong>
</a>
{{/eq}}
<form>
<div class="modal-head">
{{#eq action 'activate'}}
- <h2>{{t 'coding_rules.activate_in_quality_profile'}} ({{paging.fTotal}} {{t 'coding_rules._rules'}})</h2>
+ <h2>{{t 'coding_rules.activate_in_quality_profile'}} ({{paging.total}} {{t 'coding_rules._rules'}})</h2>
{{/eq}}
{{#eq action 'deactivate'}}
- <h2>{{t 'coding_rules.deactivate_in_quality_profile'}} ({{paging.fTotal}} {{t 'coding_rules._rules'}})</h2>
+ <h2>{{t 'coding_rules.deactivate_in_quality_profile'}} ({{paging.total}} {{t 'coding_rules._rules'}})</h2>
{{/eq}}
{{#eq action 'change-severity'}}
- <h2>{{t 'coding_rules.change_severity'}} ({{paging.fTotal}} {{t 'coding_rules._rules'}})</h2>
+ <h2>{{t 'coding_rules.change_severity'}} ({{paging.total}} {{t 'coding_rules._rules'}})</h2>
{{/eq}}
</div>
<div class="modal-body">
<div class="modal-error"></div>
- {{#notEq action 'change-severity'}}
<div class="modal-field">
- <label for="coding-rules-bulk-change-activate-on">
+ <h3><label for="coding-rules-bulk-change-profile">
+ {{#eq action 'change-severity'}}{{t 'coding_rules.change_severity_in'}}{{/eq}}
{{#eq action 'activate'}}{{t 'coding_rules.activate_in'}}{{/eq}}
{{#eq action 'deactivate'}}{{t 'coding_rules.deactivate_in'}}{{/eq}}
- </label>
+ </label></h3>
+ {{#if qualityProfile}}
+ <h3 class="readonly-field">{{qualityProfileName}}</h3>
+ {{else}}
<select id="coding-rules-bulk-change-profile">
{{#each availableQualityProfiles}}
<option value="{{key}}">{{name}}</option>
{{/each}}
</select>
- </div>
- {{/notEq}}
+ {{/if}}
+ </div>
{{#eq action 'change-severity'}}
{{#if qualityProfile}}
<div class="modal-field">
- <label for="coding-rules-bulk-change-severity">{{t 'coding_rules.change_severity'}}</label>
+ <h3><label for="coding-rules-bulk-change-severity">{{t 'severity'}}</label></h3>
<select id="coding-rules-bulk-change-severity">
{{#each severities}}
<option value="{{this}}">{{t 'severity' this}}</option>
}
}
+.readonly-field {
+ padding-top: 5px;
+ line-height: 1;
+}
+
.modal-field input {
margin-right: 5px;
margin-bottom: 10px;