aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/custom-measures/create-view.js
blob: d7461fe715882fbface989edbacd864ba4c3ed79 (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
32
define([
  './custom-measure',
  './form-view'
], function (CustomMeasure, FormView) {

  return FormView.extend({

    sendRequest: function () {
      var that = this,
          customMeasure = new CustomMeasure({
            metricId: this.$('#create-custom-measure-metric').val(),
            value: this.$('#create-custom-measure-value').val(),
            description: this.$('#create-custom-measure-description').val(),
            projectId: this.options.projectId
          });
      this.disableForm();
      return customMeasure.save(null, {
        statusCode: {
          // do not show global error
          400: null
        }
      }).done(function () {
        that.collection.refresh();
        that.destroy();
      }).fail(function (jqXHR) {
        that.enableForm();
        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
      });
    }
  });

});