aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/provisioning/bulk-delete-view.js
blob: 731e3e163d2d22bd14e792ab41aa6f1a5ee286a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
define([
  'components/common/modal-form',
  './templates'
], function (ModalForm) {

  return ModalForm.extend({
    template: Templates['provisioning-bulk-delete'],

    onFormSubmit: function (e) {
      this._super(e);
      this.sendRequest();
    },

    sendRequest: function () {
      var that = this,
          selected = _.pluck(this.collection.where({ selected: true }), 'id');
      return this.collection.bulkDelete(selected, {
        statusCode: {
          // do not show global error
          400: null
        }
      }).done(function () {
        that.collection.refresh();
        that.destroy();
      }).fail(function (jqXHR) {
        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
      });
    }
  });

});