summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js
blob: fff83f3af3bb3c034d12328645e12b8cc3e83e7f (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(item, $el, e) {
        e.preventDefault();
        onSelect();
      },
    });
  }
}