debian-mirror-gitlab/app/assets/javascripts/groups/transfer_dropdown.js

38 lines
894 B
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2019-07-31 22:56:46 +05:30
import { __ } from '~/locale';
2018-05-09 12:01:36 +05:30
2018-03-17 18:26:18 +05:30
export default class TransferDropdown {
constructor() {
this.groupDropdown = $('.js-groups-dropdown');
this.parentInput = $('#new_parent_group_id');
this.data = this.groupDropdown.data('data');
this.init();
}
init() {
this.buildDropdown();
}
buildDropdown() {
2019-07-31 22:56:46 +05:30
const extraOptions = [{ id: '', text: __('No parent group') }, 'divider'];
2018-03-17 18:26:18 +05:30
this.groupDropdown.glDropdown({
selectable: true,
filterable: true,
toggleLabel: item => item.text,
search: { fields: ['text'] },
data: extraOptions.concat(this.data),
text: item => item.text,
2018-12-13 13:39:08 +05:30
clicked: options => {
2018-03-17 18:26:18 +05:30
const { e } = options;
e.preventDefault();
this.assignSelected(options.selectedObj);
},
});
}
assignSelected(selected) {
this.parentInput.val(selected.id);
}
}