aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/users/groups-view.js
blob: 6a874070b660b968b0233fc38f6a8c94a825366b (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
define([
  'components/common/modals',
  'components/common/select-list',
  './templates'
], function (Modal) {

  return Modal.extend({
    template: Templates['users-groups'],
    itemTemplate: Templates['users-group'],

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

    onClose: function () {
      this.model.collection.refresh();
      Modal.prototype.onClose.apply(this, arguments);
    }
  });

});