aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/project-permissions/users-view.js
blob: 5f54a1ad2a90a233b3fc748196f8a0d22af1b4e8 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
define([
  'components/common/modals',
  'components/common/select-list',
  './templates'
], function (Modal) {

  return Modal.extend({
    template: Templates['project-permissions-users'],

    onRender: function () {
      this._super();
      new window.SelectList({
        el: this.$('#project-permissions-users'),
        width: '100%',
        readOnly: false,
        focusSearch: false,
        format: function (item) {
          return item.name + '<br><span class="note">' + item.login + '</span>';
        },
        queryParam: 'q',
        searchUrl: baseUrl + '/api/permissions/users?ps=100&permission=' + this.options.permission + '&projectId=' + this.options.project,
        selectUrl: baseUrl + '/api/permissions/add_user',
        deselectUrl: baseUrl + '/api/permissions/remove_user',
        extra: {
          permission: this.options.permission,
          projectId: this.options.project
        },
        selectParameter: 'login',
        selectParameterValue: 'login',
        parse: function (r) {
          this.more = false;
          return r.users;
        }
      });
    },

    onDestroy: function () {
      this.options.refresh && this.options.refresh();
      this._super();
    },

    serializeData: function () {
      return _.extend(Modal.prototype.serializeData.apply(this, arguments), {
        projectName: this.options.projectName
      })
    }
  });

});