Fix nested group key path for m2o fields

This commit is contained in:
rijkvanzanten
2022-03-16 11:38:51 -04:00
parent 5a77ac2f30
commit bdfa50d9cb
2 changed files with 15 additions and 7 deletions

View File

@@ -6,14 +6,16 @@
@click="$emit('add', field.key)"
>
<v-list-item-content>
<v-text-overflow :text="field.name || formatTitle(field.field)" :highlight="search" />
{{ field.key }}
<!-- <v-text-overflow :text="field.name || formatTitle(field.field)" :highlight="search" /> -->
</v-list-item-content>
</v-list-item>
<v-list-group v-else :clickable="!field.disabled" :value="field.key" @click="$emit('add', field.key)">
<v-list-group v-else :clickable="!field.disabled" :value="field.path" @click="$emit('add', field.key)">
<template #activator>
<v-list-item-content>
<v-text-overflow :text="field.name || formatTitle(field.field)" :highlight="search" />
{{ field.key }}
<!-- <v-text-overflow :text="field.name || formatTitle(field.field)" :highlight="search" /> -->
</v-list-item-content>
</template>
@@ -40,6 +42,7 @@ type FieldInfo = {
field: string;
name: string;
key: string;
path: string;
disabled?: boolean;
children?: FieldInfo[];
};

View File

@@ -10,6 +10,7 @@ export type FieldNode = {
collection: string;
relatedCollection?: string;
key: string;
path: string;
children?: FieldNode[];
group?: boolean;
};
@@ -71,7 +72,8 @@ export function useFieldTree(
function makeNode(field: Field, allFields: Field[], parent?: FieldNode): FieldNode | FieldNode[] {
const relatedCollections = getRelatedCollections(field);
const context = parent ? parent.key + '.' : '';
const pathContext = parent ? parent.path + '.' : '';
const keyContext = parent && !parent.group ? parent.key + '.' : '';
if (field?.meta?.special?.includes('group')) {
const node: FieldNode = {
@@ -79,7 +81,8 @@ export function useFieldTree(
field: field.field,
collection: field.collection,
relatedCollection: undefined,
key: context + field.field,
key: field.field,
path: pathContext + field.field,
group: true,
};
@@ -95,7 +98,8 @@ export function useFieldTree(
field: field.field,
collection: field.collection,
relatedCollection: relatedCollections[0],
key: context + field.field,
key: keyContext + field.field,
path: pathContext + field.field,
};
}
@@ -105,7 +109,8 @@ export function useFieldTree(
field: `${field.field}:${collection}`,
collection: field.collection,
relatedCollection: collection,
key: context + `${field.field}:${collection}`,
key: keyContext + `${field.field}:${collection}`,
path: pathContext + `${field.field}:${collection}`,
};
});
}