2021-01-31 02:43:13 +13:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div class="flex justify-start items-center text-weight-bolder q-mb-sm q-mt-md">
|
2021-02-09 15:21:48 +13:00
|
|
|
<q-icon v-if="inputIcon" :name="inputIcon" :size="inputIcon.includes('fas')? '15px': '20px'" class="q-mr-md"/>
|
2021-01-31 02:43:13 +13:00
|
|
|
{{inputDataBluePrint.name}}
|
2021-02-21 01:06:21 +13:00
|
|
|
<q-icon v-if="toolTip" name="mdi-help-circle" size="16px" class="q-ml-md">
|
|
|
|
<q-tooltip>
|
|
|
|
<span v-html="toolTip"/>
|
|
|
|
</q-tooltip>
|
|
|
|
</q-icon>
|
2021-01-31 02:43:13 +13:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<q-list
|
|
|
|
v-if="!editMode"
|
|
|
|
dense>
|
|
|
|
<q-item v-for="(input,index) in localInput" :key="index">
|
|
|
|
<q-item-section side>
|
|
|
|
<q-icon name="mdi-menu-right" />
|
|
|
|
</q-item-section>
|
|
|
|
<q-item-section>
|
|
|
|
{{input}}
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
</q-list>
|
|
|
|
|
|
|
|
<q-select
|
|
|
|
v-if="editMode"
|
|
|
|
style="width: 100%;"
|
|
|
|
dense
|
|
|
|
:options="extraInput"
|
|
|
|
use-input
|
|
|
|
outlined
|
|
|
|
use-chips
|
2021-02-09 15:21:48 +13:00
|
|
|
@filter="filterFn"
|
2021-01-31 02:43:13 +13:00
|
|
|
input-debounce="0"
|
|
|
|
new-value-mode="add"
|
|
|
|
multiple
|
|
|
|
v-model="localInput"
|
|
|
|
@input="signalInput"
|
|
|
|
@keydown="signalInput"
|
|
|
|
>
|
|
|
|
</q-select>
|
|
|
|
|
2021-02-09 15:21:48 +13:00
|
|
|
<div class="separatorWrapper">
|
|
|
|
<q-separator color="grey q-mt-lg" />
|
|
|
|
</div>
|
2021-01-31 02:43:13 +13:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Emit, Prop, Watch } from "vue-property-decorator"
|
|
|
|
|
|
|
|
import BaseClass from "src/BaseClass"
|
|
|
|
|
|
|
|
import { I_ExtraFields } from "src/interfaces/I_Blueprint"
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
components: { }
|
|
|
|
})
|
|
|
|
export default class Field_MultiSelect extends BaseClass {
|
|
|
|
@Prop({ default: [] }) readonly inputDataBluePrint!: I_ExtraFields
|
|
|
|
|
|
|
|
@Prop({ default: [] }) readonly inputDataValue!: []
|
|
|
|
|
|
|
|
@Prop() readonly isNew!: boolean
|
|
|
|
|
|
|
|
@Prop() readonly editMode!: boolean
|
|
|
|
|
|
|
|
changedInput = false
|
|
|
|
localInput = []
|
|
|
|
|
|
|
|
@Watch("inputDataValue", { deep: true, immediate: true })
|
|
|
|
reactToInputChanges () {
|
|
|
|
this.localInput = (this.inputDataValue) ? this.inputDataValue : []
|
|
|
|
}
|
|
|
|
|
|
|
|
get inputIcon () {
|
|
|
|
return this.inputDataBluePrint?.icon
|
|
|
|
}
|
|
|
|
|
2021-02-21 01:06:21 +13:00
|
|
|
get toolTip () {
|
|
|
|
return this.inputDataBluePrint?.tooltip
|
|
|
|
}
|
|
|
|
|
2021-02-09 15:21:48 +13:00
|
|
|
extraInput: string[] = []
|
|
|
|
|
|
|
|
@Watch("inputDataBluePrint", { deep: true, immediate: true })
|
|
|
|
populateExtraInput () {
|
|
|
|
if (this.inputDataBluePrint?.predefinedSelectValues) {
|
|
|
|
this.extraInput = this.inputDataBluePrint?.predefinedSelectValues
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
filterFn (val: string, update: (fn: any) => void) {
|
|
|
|
if (val === "") {
|
|
|
|
update(() => {
|
|
|
|
if (this.inputDataBluePrint?.predefinedSelectValues) {
|
|
|
|
this.extraInput = this.inputDataBluePrint.predefinedSelectValues
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
update(() => {
|
|
|
|
if (this.inputDataBluePrint?.predefinedSelectValues) {
|
|
|
|
const needle = val.toLowerCase()
|
|
|
|
this.extraInput = this.inputDataBluePrint.predefinedSelectValues.filter(v => v.toLowerCase().indexOf(needle) > -1)
|
|
|
|
}
|
|
|
|
})
|
2021-01-31 02:43:13 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
@Emit()
|
|
|
|
signalInput () {
|
|
|
|
this.changedInput = true
|
|
|
|
return this.localInput
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|