mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-12 12:16:06 +08:00
06788bfeb6
* Update css for bmt filters [SCI-6084] * Create shared component for dropdown [SCI-6084] Co-authored-by: Anton <anton@scinote.net>
59 lines
No EOL
1.3 KiB
Vue
59 lines
No EOL
1.3 KiB
Vue
<template>
|
|
<div class="dropdown-selector">
|
|
<select :id="this.selectorId">
|
|
<option
|
|
v-for="option in this.options"
|
|
:key="option.label" :value="option.value">
|
|
{{ option.label }}
|
|
</option>
|
|
</select>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'DropdownSelector',
|
|
props: {
|
|
options: Array,
|
|
selectorId: String,
|
|
noEmptyOption: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
singleSelect: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
closeOnSelect: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
selectAppearance: {
|
|
type: String,
|
|
default: 'simple'
|
|
},
|
|
onChange: Function
|
|
|
|
},
|
|
mounted: function() {
|
|
dropdownSelector.init(`#${this.selectorId}`, {
|
|
noEmptyOption: this.noEmptyOption,
|
|
singleSelect: this.singleSelect,
|
|
closeOnSelect: this.closeOnSelect,
|
|
selectAppearance: this.selectAppearance,
|
|
onChange: () => {
|
|
if (this.onChange) this.onChange();
|
|
this.selectChanged(dropdownSelector.getValues(`#${this.selectorId}`))
|
|
}
|
|
});
|
|
},
|
|
methods: {
|
|
selectChanged(value) {
|
|
this.$emit(
|
|
'dropdown:changed',
|
|
value
|
|
);
|
|
}
|
|
}
|
|
}
|
|
</script> |