'coding-rules/views/coding-rules-list-view',
'coding-rules/views/coding-rules-bulk-change-view',
'coding-rules/views/coding-rules-quality-profile-activation-view',
+ 'coding-rules/views/coding-rules-bulk-change-dropdown-view'
# filters
'navigator/filters/base-filters',
CodingRulesListView,
CodingRulesBulkChangeView,
CodingRulesQualityProfileActivationView,
+ CodingRulesBulkChangeDropdownView
# filters
BaseFilters,
@layout.actionsRegion.show @codingRulesActionsView
- # Construct bulk change view
+ # Construct bulk change views
App.addInitializer ->
@codingRulesBulkChangeView = new CodingRulesBulkChangeView app: @
+ @codingRulesBulkChangeDropdownView = new CodingRulesBulkChangeDropdownView app: @
# Construct quality profile activation view
'severity.INFO': 'Info'
'coding_rules.activate': 'Activate'
- 'coding_rules.activate_in_quality_profile': 'Activate in Quality Profile'
+ 'coding_rules.activate_in': 'Activate In'
+ 'coding_rules.activate_in_quality_profile': 'Activate In Quality Profile'
'coding_rules.add_note': 'Add Note'
'coding_rules.available_since': 'Available Since'
'coding_rules.bulk_change': 'Bulk Change'
+ 'coding_rules.change_severity': 'Change Severity'
+ 'coding_rules.change_severity_in': 'Change Severity In'
'coding_rules.extend_description': 'Extend Description'
+ 'coding_rules.deactivate_in': 'Deactivate In'
'coding_rules.deactivate_quality_profile': 'Deactivate'
+ 'coding_rules.deactivate_in_quality_profile': 'Deactivate In Quality Profile'
'coding_rules.found': 'Found'
'coding_rules._inherits': 'inherits'
'coding_rules.key': 'Key:'
'coding_rules.quality_profile': 'Quality Profile'
'coding_rules.repository': 'Repository:'
'coding_rules.revert_to_parent_definition': 'Revert to Parent Definition'
- 'coding_rules._rules': 'rule(s)'
+ 'coding_rules._rules': 'rules'
'coding_rules.select_tag': 'Select Tag'
'coding_rules.filters.availableSince': 'Available Since'
define [
- 'backbone.marionette',
+ 'backbone.marionette'
'templates/coding-rules'
], (
- Marionette,
+ Marionette
Templates
) ->
ui:
orderChoices: '.navigator-actions-order-choices'
+ bulkChange: '.navigator-actions-bulk'
events:
'click .navigator-actions-order': 'toggleOrderChoices'
'click @ui.orderChoices': 'sort'
- 'click .navigator-actions-bulk': 'bulkChange'
+ 'click @ui.bulkChange': 'bulkChange'
onRender: ->
@options.app.fetchFirstPage()
- bulkChange: ->
- @options.app.codingRulesBulkChangeView.show()
+ bulkChange: (e) ->
+ e.stopPropagation()
+ @options.app.codingRulesBulkChangeDropdownView.toggle()
serializeData: ->
--- /dev/null
+define [
+ 'backbone.marionette',
+ 'templates/coding-rules'
+], (
+ Marionette,
+ Templates
+) ->
+
+ class CodingRulesBulkChangeDropdownView extends Marionette.ItemView
+ className: 'coding-rules-bulk-change-dropdown'
+ template: Templates['coding-rules-bulk-change-dropdown']
+
+
+ events:
+ 'click .coding-rules-bulk-change-dropdown-link': 'doAction'
+
+
+ doAction: (e) ->
+ action = jQuery(e.target).data 'action'
+ param = jQuery(e.target).data 'param'
+ unless param
+ @options.app.codingRulesBulkChangeView.show action
+ else
+ query = @options.app.getQuery()
+ switch action
+ when 'activate' then _.extend query, bulk_activate: [param]
+ when 'deactivate' then _.extend query, bulk_deactivate: [param]
+ @options.app.codingRulesBulkChangeView.bulkChange query
+
+
+ onRender: ->
+ jQuery('body').append @el
+ jQuery('body').off('click.bulk-change').on 'click.bulk-change', => @hide()
+
+
+ toggle: ->
+ if @$el.is(':visible') then @hide() else @show()
+
+
+ show: ->
+ @render()
+ @$el.show()
+
+
+ hide: ->
+ @$el.hide()
+
+
+ serializeData: ->
+ activeQualityProfile: @options.app.getActiveQualityProfile()
+ activeQualityProfileName: @options.app.activeInFilter.view.renderValue()
+ inactiveQualityProfile: @options.app.getInactiveQualityProfile()
+ inactiveQualityProfileName: @options.app.inactiveInFilter.view.renderValue()
\ No newline at end of file
escapeMarkup: (m) -> m
- show: ->
+ show: (action) ->
+ @action = action
@render()
@$el.dialog 'open'
prepareQuery: ->
query = @options.app.getQuery()
- activateIn = []
- deactivateIn = []
- severity = null
- if @$('#coding-rules-bulk-change-activate-qp').is(':checked')
- activateIn.push @options.app.getInactiveQualityProfile()
- if @$('#coding-rules-bulk-change-activate').is(':checked')
- activateIn.push @$('#coding-rules-bulk-change-activate-on').val()
- if @$('#coding-rules-bulk-change-deactivate-qp').is(':checked')
- deactivateIn.push @options.app.getActiveQualityProfile()
- if @$('#coding-rules-bulk-change-deactivate').is(':checked')
- deactivateIn.push @$('#coding-rules-bulk-change-deactivate-on').val()
- if @$('#coding-rules-bulk-change-set-severity').is(':checked')
- severity = @$('#coding-rules-bulk-change-severity').val()
- actions = []
- if activateIn.length > 0
- actions.push 'bulk_activate'
- _.extend query, bulk_activate_in: activateIn.join(',')
- if deactivateIn.length > 0
- actions.push 'bulk_deactivate'
- _.extend query, bulk_deactivate_in: deactivateIn.join(',')
- if severity
- actions.push 'bulk_set_severity'
- _.extend query, bulk_severity: severity
- _.extend query, bulk_actions: actions
+ switch @action
+ when 'activate' then _.extend query, bulk_activate: @$('#coding-rules-bulk-change-activate-on').val()
+ when 'deactivate' then _.extend query, bulk_deactivate: @$('#coding-rules-bulk-change-deactivate-on').val()
+ when 'change-severity' then _.extend query, bulk_change_severity: @$('#coding-rules-bulk-change-severity').val()
- onSubmit: (e) ->
- e.preventDefault()
+
+ bulkChange: (query) ->
jQuery.ajax
type: 'POST'
url: "#{baseUrl}/api/codingrules/bulk_change"
- data: @prepareQuery()
+ data: query
.done =>
@options.app.fetchFirstPage()
- @hide()
+
+ onSubmit: (e) ->
+ e.preventDefault()
+ @bulkChange(@prepareQuery()).done => @hide()
serializeData: ->
+ action: @action
+
paging: @options.app.codingRules.paging
qualityProfiles: @options.app.qualityProfiles
margin-top: -3px;
margin-left: @navigatorPadding;
}
+
+
+// Bulk Change
+.coding-rules-bulk-change-dropdown {
+ position: fixed;
+ z-index: 10;
+ top: @navigatorTopOffset + @navigatorHeaderHeight + @navigatorFiltersHeight + @navigatorStatusHeight - 1px;
+ left: @navigatorResultsWidth - 200px;
+ width: 200px;
+ border: 1px solid @navigatorBorderLightColor;
+ .box-sizing(border-box);
+ background-color: #fff;
+}
+
+.coding-rules-bulk-change-dropdown-link {
+ display: block;
+ height: 30px;
+ line-height: 30px;
+ padding: 0 @navigatorPadding;
+ font-size: @smallFontSize;
+ .trans;
+
+ &:hover { background-color: @navigatorBarBackground; }
+
+ strong { font-weight: bold; }
+}
\ No newline at end of file
--- /dev/null
+<a class="coding-rules-bulk-change-dropdown-link" data-action="activate"
+ {{#if inactiveQualityProfile}}data-param="{{inactiveQualityProfile}}"{{/if}}>
+ {{t 'coding_rules.activate_in'}}
+ {{#if inactiveQualityProfile}}<strong>{{inactiveQualityProfileName}}</strong>{{/if}}
+</a>
+
+<a class="coding-rules-bulk-change-dropdown-link" data-action="deactivate"
+ {{#if activeQualityProfile}}data-param="{{activeQualityProfile}}"{{/if}}>
+ {{t 'coding_rules.deactivate_in'}}
+ {{#if activeQualityProfile}}<strong>{{activeQualityProfileName}}</strong>{{/if}}
+</a>
+
+{{#if activeQualityProfile}}
+ <a class="coding-rules-bulk-change-dropdown-link" data-action="change-severity">
+ {{t 'coding_rules.change_severity_in'}} <strong>{{activeQualityProfileName}}</strong>
+ </a>
+{{/if}}
\ No newline at end of file
<form>
<div class="modal-head">
- <h2>{{t 'coding_rules.bulk_change'}} {{paging.fTotal}} {{t 'coding_rules._rules'}}</h2>
+ {{#eq action 'activate'}}
+ <h2>{{t 'coding_rules.activate_in_quality_profile'}} ({{paging.fTotal}} {{t 'coding_rules._rules'}})</h2>
+ {{/eq}}
+ {{#eq action 'deactivate'}}
+ <h2>{{t 'coding_rules.deactivate_in_quality_profile'}} ({{paging.fTotal}} {{t 'coding_rules._rules'}})</h2>
+ {{/eq}}
+ {{#eq action 'change-severity'}}
+ <h2>{{t 'coding_rules.change_severity'}} ({{paging.fTotal}} {{t 'coding_rules._rules'}})</h2>
+ {{/eq}}
</div>
<div class="modal-body">
<div class="modal-error"></div>
- {{#if inactiveQualityProfile}}
+ {{#eq action 'activate'}}
<div class="modal-field">
- <label for="coding-rules-bulk-change-activate-on-qp">Activate on</label>
- <input id="coding-rules-bulk-change-activate-qp" type="checkbox">
- <span class="text">{{inactiveQualityProfileName}}</span>
- </div>
- {{/if}}
-
- <div class="modal-field">
- <label for="coding-rules-bulk-change-activate-on">{{#unless inactiveQualityProfile}}Activate on{{/unless}}</label>
- <input id="coding-rules-bulk-change-activate" type="checkbox">
- <select id="coding-rules-bulk-change-activate-on" multiple>
- {{#each activateOnQualityProfiles}}
- <option value="{{key}}">{{name}}</option>
- {{/each}}
- </select>
- </div>
-
- {{#if activeQualityProfile}}
- <div class="modal-field">
- <label for="coding-rules-bulk-change-deactivate-on-qp">Deactivate on</label>
- <input id="coding-rules-bulk-change-deactivate-qp" type="checkbox">
- <span class="text">{{activeQualityProfileName}}</span>
+ <label for="coding-rules-bulk-change-activate-on">{{t 'coding_rules.activate_in'}}</label>
+ <select id="coding-rules-bulk-change-activate-on" multiple>
+ {{#each activateOnQualityProfiles}}
+ <option value="{{key}}">{{name}}</option>
+ {{/each}}
+ </select>
</div>
- {{/if}}
+ {{/eq}}
- <div class="modal-field">
- <label for="coding-rules-bulk-change-deactivate-on">{{#unless activeQualityProfile}}Deactivate on{{/unless}}</label>
- <input id="coding-rules-bulk-change-deactivate" type="checkbox">
- <select id="coding-rules-bulk-change-deactivate-on" multiple>
- {{#each deactivateOnQualityProfiles}}
- <option value="{{key}}">{{name}}</option>
- {{/each}}
- </select>
- </div>
-
- {{#if activeQualityProfile}}
+ {{#eq action 'deactivate'}}
<div class="modal-field">
- <label for="coding-rules-bulk-change-severity">Change Severity</label>
- <input id="coding-rules-bulk-change-set-severity" type="checkbox">
- <select id="coding-rules-bulk-change-severity">
- {{#each severities}}
- <option value="{{this}}">{{t 'severity' this}}</option>
+ <label for="coding-rules-bulk-change-deactivate-on">{{t 'coding_rules.deactivate_in'}}</label>
+ <select id="coding-rules-bulk-change-deactivate-on" multiple>
+ {{#each deactivateOnQualityProfiles}}
+ <option value="{{key}}">{{name}}</option>
{{/each}}
</select>
</div>
- {{/if}}
+ {{/eq}}
+
+ {{#eq action 'change-severity'}}
+ {{#if activeQualityProfile}}
+ <div class="modal-field">
+ <label for="coding-rules-bulk-change-severity">{{t 'coding_rules.change_severity'}}</label>
+ <select id="coding-rules-bulk-change-severity">
+ {{#each severities}}
+ <option value="{{this}}">{{t 'severity' this}}</option>
+ {{/each}}
+ </select>
+ </div>
+ {{/if}}
+ {{/eq}}
</div>
<div class="modal-foot">
<h3 class="coding-rules-detail-title">{{t 'coding_rules.quality_profiles'}}</h3>
<div class="button-group coding-rules-detail-quality-profiles-activation">
- <button id="coding-rules-quality-profile-activate">{{t 'coding_rules.activate_quality_profile'}}</button>
+ <button id="coding-rules-quality-profile-activate">{{t 'coding_rules.activate_in_quality_profile'}}</button>
</div>
<div id="coding-rules-detail-quality-profiles"></div>
\ No newline at end of file