scinote-web/app/javascript/vue/shared/dropdown_selector.vue
aignatov-bio 06788bfeb6
Update CSS for BMT filters [SCI-6084] (#3652)
* Update css for bmt filters [SCI-6084]

* Create shared component for dropdown [SCI-6084]

Co-authored-by: Anton <anton@scinote.net>
2021-11-16 14:46:08 +01:00

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>