2019-07-07 11:18:12 +05:30
|
|
|
<script>
|
|
|
|
import $ from 'jquery';
|
2019-07-31 22:56:46 +05:30
|
|
|
import 'select2';
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
export default {
|
2019-10-12 21:52:04 +05:30
|
|
|
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
|
2020-04-22 19:07:51 +05:30
|
|
|
// eslint-disable-next-line @gitlab/require-i18n-strings
|
2019-07-07 11:18:12 +05:30
|
|
|
name: 'Select2Select',
|
|
|
|
props: {
|
|
|
|
options: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
value: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
$(this.$refs.dropdownInput)
|
|
|
|
.val(this.value)
|
|
|
|
.select2(this.options)
|
|
|
|
.on('change', event => this.$emit('input', event.target.value));
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeDestroy() {
|
|
|
|
$(this.$refs.dropdownInput).select2('destroy');
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<input ref="dropdownInput" type="hidden" />
|
|
|
|
</template>
|