summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/protected_branches/protected_branch_access_dropdown.js
blob: 40a873833e1697f0cdcc4ba6a8235dc5374a02ec (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
export default class ProtectedBranchAccessDropdown {
  constructor(options) {
    this.options = options;
    this.initDropdown();
  }

  initDropdown() {
    const { $dropdown, data, onSelect } = this.options;
    $dropdown.glDropdown({
      data,
      selectable: true,
      inputId: $dropdown.data('inputId'),
      fieldName: $dropdown.data('fieldName'),
      toggleLabel(item, $el) {
        if ($el.is('.is-active')) {
          return item.text;
        }
        return 'Select';
      },
      clicked(options) {
        options.e.preventDefault();
        onSelect();
      },
    });
  }
}