debian-mirror-gitlab/app/assets/javascripts/protected_branches/protected_branch_access_dropdown.js

29 lines
641 B
JavaScript
Raw Normal View History

2019-07-31 22:56:46 +05:30
import { __ } from '~/locale';
2017-09-10 17:25:29 +05:30
export default class ProtectedBranchAccessDropdown {
constructor(options) {
this.options = options;
this.initDropdown();
}
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
initDropdown() {
const { $dropdown, data, onSelect } = this.options;
$dropdown.glDropdown({
data,
selectable: true,
2018-03-27 19:54:05 +05:30
inputId: $dropdown.data('inputId'),
fieldName: $dropdown.data('fieldName'),
2017-09-10 17:25:29 +05:30
toggleLabel(item, $el) {
if ($el.is('.is-active')) {
return item.text;
2016-09-13 17:45:13 +05:30
}
2019-07-31 22:56:46 +05:30
return __('Select');
2017-09-10 17:25:29 +05:30
},
clicked(options) {
options.e.preventDefault();
onSelect();
},
});
}
}