aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/users/groups-view.js
blob: 486e76f3b565dd3ec4782224981f0b54946f5a2c (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
import Modal from '../../components/common/modals';
import '../../components/common/select-list';
import Template from './templates/users-groups.hbs';

export default Modal.extend({
  template: Template,

  onRender: function () {
    Modal.prototype.onRender.apply(this, arguments);
    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/user_groups/add_user',
      deselectUrl: baseUrl + '/api/user_groups/remove_user',
      extra: {
        login: this.model.id
      },
      selectParameter: 'id',
      selectParameterValue: 'id',
      parse: function (r) {
        this.more = false;
        return r.groups;
      }
    });
  },

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