summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/issue_status_select.js
blob: 2ede083793016d2503e562e87efe891fed28ee38 (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
import $ from 'jquery';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { __ } from './locale';

export default function issueStatusSelect() {
  $('.js-issue-status').each((i, el) => {
    const fieldName = $(el).data('fieldName');
    initDeprecatedJQueryDropdown($(el), {
      selectable: true,
      fieldName,
      toggleLabel(selected, element, instance) {
        let label = __('Author');
        const $item = instance.dropdown.find('.is-active');
        if ($item.length) {
          label = $item.text();
        }
        return label;
      },
      clicked(options) {
        return options.e.preventDefault();
      },
      id(obj, element) {
        return $(element).data('id');
      },
    });
  });
}