diff --git a/src/components/fields/Group.vue b/src/components/fields/Group.vue index fd18802..cec7372 100644 --- a/src/components/fields/Group.vue +++ b/src/components/fields/Group.vue @@ -54,15 +54,19 @@ const inner = computed({ const options = ref([]); const disabled = ref(false); -async function refreshOptions() { +async function refreshOptions(clear) { if (props.field.parent_group === null && props.field.parent_field === null) { - emit('update:modelValue', null); + if (clear) { + emit('update:modelValue', null); + } options.value = (await axios.get('/api/group?prefer_inner')).data.data; disabled.value = false; return; } if (props.field.parent_group !== null) { - emit('update:modelValue', null); + if (clear) { + emit('update:modelValue', null); + } options.value = (await axios.get('/api/group/' + props.field.parent_group + '?prefer_inner')).data.data; disabled.value = false; return; @@ -74,24 +78,28 @@ async function refreshOptions() { if (!props.payload[props.field.parent_field] || props.payload[props.field.parent_field] === -1) { options.value = []; - emit('update:modelValue', null); + if (clear) { + emit('update:modelValue', null); + } disabled.value = true; return; } - emit('update:modelValue', null); + if (clear) { + emit('update:modelValue', null); + } options.value = (await axios.get('/api/group/' + props.payload[props.field.parent_field] + '?prefer_inner')).data.data; disabled.value = false; } -refreshOptions(); +refreshOptions(false); if (props.field.parent_field) { watch( () => props.payload[props.field.parent_field], function (oldValue, newValue) { if (oldValue !== newValue) { - refreshOptions(); + refreshOptions(true); } }, );