gitlab-org--gitlab-foss/app/assets/javascripts/protected_tags/protected_tag_access_dropdo...

30 lines
771 B
JavaScript
Raw Normal View History

import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { __ } from '~/locale';
2017-04-06 08:47:19 +00:00
export default class ProtectedTagAccessDropdown {
constructor(options) {
this.options = options;
this.initDropdown();
}
2017-03-21 15:51:56 +00:00
2017-04-06 08:47:19 +00:00
initDropdown() {
const { onSelect } = this.options;
initDeprecatedJQueryDropdown(this.options.$dropdown, {
2017-04-06 08:47:19 +00:00
data: this.options.data,
selectable: true,
2018-02-20 22:20:48 +00:00
inputId: this.options.$dropdown.data('inputId'),
fieldName: this.options.$dropdown.data('fieldName'),
2017-04-06 13:39:48 +00:00
toggleLabel(item, $el) {
if ($el.is('.is-active')) {
2017-04-06 08:47:19 +00:00
return item.text;
2017-03-21 15:51:56 +00:00
}
return __('Select');
2017-04-06 08:47:19 +00:00
},
2017-05-04 20:55:36 +00:00
clicked(options) {
options.e.preventDefault();
2017-04-06 08:47:19 +00:00
onSelect();
},
});
}
}