coding_rules.add_tags=Add Tags
coding_rules.available_since=Available Since
coding_rules.bulk_change=Bulk Change
+coding_rules.bulk_change.success={0} rule(s) changed
+coding_rules.bulk_change.warning={0} rule(s) changed, {1} rule(s) ignored
coding_rules.change_severity=Change Severity
coding_rules.change_severity_in=Change Severity In
coding_rules.change_details=Change Details of Quality Profile
className: 'modal'
template: Templates['coding-rules-bulk-change']
+ ui:
+ modalFooter: '.modal-foot'
+ modalError: '.modal-error'
+ modalWarning: '.modal-warning'
+ modalNotice: '.modal-notice'
+ codingRulesSubmitBulkChange: '#coding-rules-submit-bulk-change'
+ codingRulesCancelBulkChange: '#coding-rules-cancel-bulk-change'
+ codingRulesCloseBulkChange: '#coding-rules-close-bulk-change'
events:
'submit form': 'onSubmit'
- 'click #coding-rules-cancel-bulk-change': 'hide'
+ 'click @ui.codingRulesCancelBulkChange': 'hide'
+ 'click @ui.codingRulesCloseBulkChange': 'close'
'change select': 'enableAction'
@$el.dialog 'close'
+ close: ->
+ @options.app.fetchFirstPage(true)
+ @hide()
+
+
prepareQuery: ->
query = @options.app.getQuery()
wsAction = query.wsAction
query = _.omit(query, 'wsAction')
- origFooter = @$('.modal-foot').html()
- @$('.modal-foot').html '<i class="spinner"></i>'
+ @ui.modalError.hide()
+ @ui.modalWarning.hide()
+ @ui.modalNotice.hide()
+
+ origFooter = @ui.modalFooter.html()
+ @ui.modalFooter.html '<i class="spinner"></i>'
jQuery.ajax
type: 'POST'
url: "#{baseUrl}/api/qualityprofiles/#{wsAction}_rules"
data: query
- .done =>
- @options.app.fetchFirstPage(true)
- @hide()
+ .done (r) =>
+ if (r.failed)
+ @ui.modalWarning.show()
+ @ui.modalWarning.html tp('coding_rules.bulk_change.warning', r.succeeded, r.failed)
+ else
+ @ui.modalNotice.show()
+ @ui.modalNotice.html tp('coding_rules.bulk_change.success', r.succeeded)
+
+ @ui.modalFooter.html origFooter
+ @$(@ui.codingRulesSubmitBulkChange.selector).hide()
+ @$(@ui.codingRulesCancelBulkChange.selector).hide()
+ @$(@ui.codingRulesCloseBulkChange.selector).show()
.fail =>
- @$('.modal-foot').html origFooter
+ @ui.modalFooter.html origFooter
onSubmit: (e) ->
<div class="modal-body">
<div class="modal-error"></div>
+ <div class="modal-warning"></div>
+ <div class="modal-notice"></div>
<div class="modal-field">
<h3><label for="coding-rules-bulk-change-profile">
</div>
<div class="modal-foot">
- <button>{{t 'apply'}}</button>
+ <button id="coding-rules-submit-bulk-change">{{t 'apply'}}</button>
<a id="coding-rules-cancel-bulk-change" class="action">{{t 'cancel'}}</a>
+ <a id="coding-rules-close-bulk-change" class="action" style="display:none">{{t 'close'}}</a>
</div>
</form>
}
/* ------------------- MESSAGES ------------------- */
-.warning {
+.warning, .modal-warning {
border: solid 1px #FFD324;
background-color: #FFF6BF;
color: #514721;
padding: 4px;
}
-.error {
+.error, .modal-error {
border: 1px solid red;
background-color: #FF5252;
color: #eee;
margin: 0 0 4px;
padding: 4px;
-}
-.error a {
- color: #eee;
+ a {
+ color: #eee;
+ }
}
-.notice {
+.notice, .modal-notice {
border: 1px solid #9c9;
background-color: #e2f9e3;
color: #060;
color: #777;
}
-.modal-error {
- border: 1px solid red;
- background-color: #FF5252;
- color: #eee;
- margin: 0 0 4px;
- padding: 4px;
- display: none;
-}
-
-.modal-warning {
- border: solid 1px #FFD324;
- background-color: #FFF6BF;
- color: #514721;
- margin: 0 0 4px;
- padding: 4px;
+.modal-error, .modal-warning, .modal-notice {
display: none;
}