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

27 lines
645 B
JavaScript
Raw Normal View History

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;
this.options.$dropdown.glDropdown({
data: this.options.data,
selectable: true,
inputId: this.options.$dropdown.data('input-id'),
fieldName: this.options.$dropdown.data('field-name'),
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
}
2017-04-06 08:47:19 +00:00
return 'Select';
},
2017-05-04 20:55:36 +00:00
clicked(options) {
options.e.preventDefault();
2017-04-06 08:47:19 +00:00
onSelect();
},
});
}
}