aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/users/create-view.js
blob: 562e41e8d5d63a4ec4ba77ce5a35ad03f7671f6b (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
33
define([
  './user',
  './form-view'
], function (User, FormView) {

  return FormView.extend({

    sendRequest: function () {
      var that = this,
          user = new User({
            login: this.$('#create-user-login').val(),
            name: this.$('#create-user-name').val(),
            email: this.$('#create-user-email').val(),
            password: this.$('#create-user-password').val(),
            scmAccounts: this.getScmAccounts()
          });
      this.disableForm();
      return user.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);
      });
    }
  });

});