summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js
blob: d4c9a91a74a420ef475cd95d42907dc31c313b8a (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 ProtectedTagAccessDropdown {
  constructor(options) {
    this.options = options;
    this.initDropdown();
  }

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