issue_status_select.js 756 Bytes
Newer Older
1
import $ from 'jquery';
2
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
3
import { __ } from './locale';
4

5
export default function issueStatusSelect() {
Filipa Lacerda's avatar
Filipa Lacerda committed
6
  $('.js-issue-status').each((i, el) => {
Phil Hughes's avatar
Phil Hughes committed
7
    const fieldName = $(el).data('fieldName');
8
    initDeprecatedJQueryDropdown($(el), {
9 10
      selectable: true,
      fieldName,
Filipa Lacerda's avatar
Filipa Lacerda committed
11
      toggleLabel(selected, element, instance) {
12
        let label = __('Author');
Filipa Lacerda's avatar
Filipa Lacerda committed
13 14 15 16 17 18
        const $item = instance.dropdown.find('.is-active');
        if ($item.length) {
          label = $item.text();
        }
        return label;
      },
19 20 21
      clicked(options) {
        return options.e.preventDefault();
      },
Filipa Lacerda's avatar
Filipa Lacerda committed
22 23
      id(obj, element) {
        return $(element).data('id');
24 25 26 27
      },
    });
  });
}