From ca373f36b8517d938c0a9c8d27d484c33ab988f5 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Wed, 11 Jun 2014 12:14:22 +0200 Subject: [PATCH] SONAR-5135 Add confirmation for all bulk actions --- ...ing-rules-bulk-change-dropdown-view.coffee | 9 +------- .../coding-rules-bulk-change-view.coffee | 18 +++++++++++----- ...les-quality-profile-activation-view.coffee | 4 ++++ .../coding-rules-bulk-change-dropdown.hbs | 2 +- .../coding-rules/coding-rules-bulk-change.hbs | 21 +++++++++++-------- sonar-server/src/main/less/style.less | 5 +++++ 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-dropdown-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-dropdown-view.coffee index 40d1eca0fb2..865a7435546 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-dropdown-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-dropdown-view.coffee @@ -18,14 +18,7 @@ define [ 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: -> diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-view.coffee index 302fad6bec2..5c85d827d1c 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-view.coffee @@ -43,8 +43,9 @@ define [ escapeMarkup: (m) -> m - show: (action) -> + show: (action, param = null) -> @action = action + @profile = param @render() @$el.dialog 'open' @@ -59,12 +60,12 @@ define [ 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 @@ -73,17 +74,24 @@ define [ bulkChange: (query) -> wsAction = query.wsAction query = _.omit(query, 'wsAction') + + origFooter = @$('.modal-foot').html() + @$('.modal-foot').html '' + 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: -> @@ -101,7 +109,7 @@ define [ paging: @options.app.codingRules.paging qualityProfiles: @options.app.qualityProfiles - qualityProfile: @options.app.getQualityProfile() + qualityProfile: @profile qualityProfileName: @options.app.qualityProfileFilter.view.renderValue() availableQualityProfiles: @getAvailableQualityProfiles() diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee index f8b52caec95..6b7a82cd3a5 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee @@ -36,7 +36,9 @@ define [ profileKey = @model.get('key') severity = @ui.qualityProfileSeverity.val() + origFooter = @$('.modal-foot').html() @$('.modal-foot').html '' + ruleKey = @rule.get('key') jQuery.ajax type: 'POST' @@ -49,6 +51,8 @@ define [ .done => @options.app.showRule ruleKey @hide() + .fail => + @$('.modal-foot').html origFooter onRender: -> diff --git a/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change-dropdown.hbs b/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change-dropdown.hbs index 372c3a1a8ea..f0fd7ea9316 100644 --- a/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change-dropdown.hbs +++ b/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change-dropdown.hbs @@ -33,7 +33,7 @@ {{! severity }} {{#eq activation 'true'}} - + {{t 'coding_rules.change_severity_in'}} {{qualityProfileName}} {{/eq}} diff --git a/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change.hbs b/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change.hbs index dcfbf2a21a7..837ca64225c 100644 --- a/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change.hbs +++ b/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change.hbs @@ -1,38 +1,41 @@
{{#eq action 'change-severity'}} {{#if qualityProfile}}