summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/issue_status_select.js
blob: fabfd26e699eb0fd16e655d4748b858f41fba2fd (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
/* eslint-disable func-names,wrap-iife, no-shadow, no-unused-vars, one-var */
export default function issueStatusSelect() {
  $('.js-issue-status').each(function (i, el) {
    const fieldName = $(el).data('field-name');
    return $(el).glDropdown({
      selectable: true,
      fieldName,
      toggleLabel: (function (_this) {
        return function (selected, el, instance) {
          let label = 'Author';
          const $item = instance.dropdown.find('.is-active');
          if ($item.length) {
            label = $item.text();
          }
          return label;
        };
      })(this),
      clicked(options) {
        return options.e.preventDefault();
      },
      id(obj, el) {
        return $(el).data('id');
      },
    });
  });
}