-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathArrayInput.vue
More file actions
46 lines (40 loc) · 932 Bytes
/
ArrayInput.vue
File metadata and controls
46 lines (40 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<template>
<q-select
ref="arrayInput"
v-model="localValue"
use-input
use-chips
multiple
:options="options"
hide-dropdown-icon
input-debounce="0"
new-value-mode="add"
:rules="[
(value) => isRequired($t, value, attribute.definition?.required),
]"
/>
</template>
<script setup>
import { ref, watch } from 'vue';
import { isRequired } from 'src/composables/QuasarFieldRule';
const props = defineProps({
attribute: {
type: Object,
required: true,
},
});
const arrayInput = ref(null);
const options = ref(props.attribute.definition?.rules.values || null);
const localValue = ref(props.attribute.value);
watch(() => arrayInput.value, () => {
if (arrayInput.value) {
arrayInput.value.validate();
}
});
watch(() => props.attribute, () => {
localValue.value = props.attribute.value;
if (arrayInput.value) {
arrayInput.value.validate();
}
});
</script>