mirror of
https://github.com/directus/directus.git
synced 2026-01-28 13:38:10 -05:00
bunch of attempted fixes
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
:field="field"
|
||||
:fields="fieldsForGroup[index] || []"
|
||||
:values="modelValue || {}"
|
||||
:initial-values="initialValues || {}"
|
||||
:initial-values="initialVals"
|
||||
:disabled="disabled"
|
||||
:batch-mode="batchMode"
|
||||
:batch-active-fields="batchActiveFields"
|
||||
@@ -48,7 +48,7 @@
|
||||
:field="field"
|
||||
:autofocus="index === firstEditableFieldIndex && autofocus"
|
||||
:model-value="(values || {})[field.field]"
|
||||
:initial-value="(initialValues || {})[field.field]"
|
||||
:initial-value="initialVals[field.field]"
|
||||
:disabled="isDisabled(field)"
|
||||
:batch-mode="batchMode"
|
||||
:batch-active="batchActiveFields.includes(field.field)"
|
||||
@@ -79,7 +79,7 @@ import { applyConditions } from '@/utils/apply-conditions';
|
||||
import { extractFieldFromFunction } from '@/utils/extract-field-from-function';
|
||||
import { Field, FieldMeta, ValidationError } from '@directus/shared/types';
|
||||
import { assign, cloneDeep, isEqual, isNil, omit, pick } from 'lodash';
|
||||
import { computed, defineComponent, onBeforeUpdate, PropType, provide, ref, watch, unref } from 'vue';
|
||||
import { computed, defineComponent, onBeforeUpdate, PropType, provide, ref, watch, inject } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import FormField from './form-field.vue';
|
||||
import ValidationErrors from './validation-errors.vue';
|
||||
@@ -164,8 +164,13 @@ export default defineComponent({
|
||||
throw new Error('[v-form]: You need to pass either the collection or fields prop.');
|
||||
});
|
||||
|
||||
const initialVals = Object.freeze(props.initialValues || {});
|
||||
|
||||
const values = computed(() => {
|
||||
return Object.assign({}, props.initialValues, props.modelValue);
|
||||
if (props.nested) {
|
||||
return inject('values', ref<Record<string, any>>({}));
|
||||
}
|
||||
return Object.assign({}, initialVals, props.modelValue);
|
||||
});
|
||||
|
||||
const el = ref<Element>();
|
||||
@@ -218,7 +223,9 @@ export default defineComponent({
|
||||
}
|
||||
);
|
||||
|
||||
provide('values', values);
|
||||
if (!props.nested) {
|
||||
provide('values', values);
|
||||
}
|
||||
|
||||
return {
|
||||
t,
|
||||
@@ -241,6 +248,7 @@ export default defineComponent({
|
||||
scrollToField,
|
||||
formFieldEls,
|
||||
fieldsMeta,
|
||||
initialVals,
|
||||
};
|
||||
|
||||
function useForm() {
|
||||
@@ -293,7 +301,7 @@ export default defineComponent({
|
||||
|
||||
const { formFields } = useFormFields(fieldsInGroup);
|
||||
|
||||
const fieldsForGroup = computed(() =>
|
||||
const fieldsForGroup = Object.freeze(
|
||||
formFields.value.map((field: Field) => getFieldsForGroup(field.meta?.field || null))
|
||||
);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
:key="accordionField.field"
|
||||
:field="accordionField"
|
||||
:fields="fields"
|
||||
:values="values"
|
||||
:values="internalValues"
|
||||
:initial-values="initialValues"
|
||||
:disabled="disabled"
|
||||
:batch-mode="batchMode"
|
||||
@@ -27,7 +27,7 @@ import { Field } from '@directus/shared/types';
|
||||
import { defineComponent, PropType, computed, ref, watch } from 'vue';
|
||||
import { ValidationError } from '@directus/shared/types';
|
||||
import AccordionSection from './accordion-section.vue';
|
||||
import { isEqual } from 'lodash';
|
||||
import { isEqual, pick } from 'lodash';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'InterfaceGroupAccordion',
|
||||
@@ -95,6 +95,7 @@ export default defineComponent({
|
||||
});
|
||||
|
||||
const selection = ref<string[]>([]);
|
||||
const internalValues = ref<Record<string, unknown>>({});
|
||||
|
||||
watch(
|
||||
() => props.start,
|
||||
@@ -122,7 +123,21 @@ export default defineComponent({
|
||||
}
|
||||
);
|
||||
|
||||
return { rootFields, selection, toggleAll };
|
||||
watch(
|
||||
() => props.values,
|
||||
() => {
|
||||
const newValue = pick(
|
||||
props.values,
|
||||
rootFields.value.map((f) => f.field)
|
||||
);
|
||||
if (!isEqual(newValue, internalValues.value)) {
|
||||
internalValues.value = newValue;
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
return { rootFields, selection, toggleAll, internalValues };
|
||||
|
||||
function toggleAll() {
|
||||
if (props.accordionMode === true) return;
|
||||
|
||||
Reference in New Issue
Block a user