- Remove external JS and CSS dependencies - Use Vuejs runtime - Add xss sanitizer - Normalize Laravel mix + add cleaner - Update npm deps - Upgrade bootswatch theme
52 lines
1.4 KiB
Vue
52 lines
1.4 KiB
Vue
<template>
|
|
<div>
|
|
<v-select v-model="value" :options="labels" @search="addOption"/>
|
|
<input type="hidden" :value="inputValue" :name="name" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
mounted() {
|
|
let data = JSON.parse(this.$parent.$options.json)
|
|
this.name = data.name
|
|
this.labels = data.labels
|
|
this.inputValue = data.value
|
|
this.value = {
|
|
code: this.labels.length,
|
|
label: this.inputValue
|
|
}
|
|
for (let label of this.labels) {
|
|
label.default = true
|
|
if (label.label == this.dbValue) {
|
|
this.value = label
|
|
}
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
name: '',
|
|
value: {},
|
|
inputValue: '',
|
|
labels: []
|
|
}
|
|
},
|
|
watch: {
|
|
value() {
|
|
this.inputValue = this.value.label
|
|
}
|
|
},
|
|
methods: {
|
|
addOption(newOption) {
|
|
if(newOption.length) {
|
|
for (let key in this.labels) {
|
|
if(!this.labels[key].default) {
|
|
this.labels.splice(key, 1)
|
|
}
|
|
}
|
|
this.labels.push({label: newOption, code: this.labels.length})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|