Dont clear groups field on first init
This commit is contained in:
parent
b65ae906b2
commit
42c0ff065f
src/components/fields
|
@ -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);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue