diff --git a/models/server-document/src/index.ts b/models/server-document/src/index.ts index 4ceb709be7..ad51427a03 100644 --- a/models/server-document/src/index.ts +++ b/models/server-document/src/index.ts @@ -33,7 +33,7 @@ export function createModel (builder: Builder): void { component: document.component.DocumentSearchIcon, props: ['icon', 'color'] }, - title: 'name' + title: 'title' } }) } diff --git a/plugins/document-resources/src/index.ts b/plugins/document-resources/src/index.ts index 00e7d33ba5..72b151e4ae 100644 --- a/plugins/document-resources/src/index.ts +++ b/plugins/document-resources/src/index.ts @@ -68,7 +68,7 @@ async function queryDocument ( search: string, filter?: { in?: RelatedDocument[], nin?: RelatedDocument[] } ): Promise { - const q: DocumentQuery = { name: { $like: `%${search}%` } } + const q: DocumentQuery = { title: { $like: `%${search}%` } } if (filter?.in !== undefined || filter?.nin !== undefined) { q._id = {} if (filter.in !== undefined) { diff --git a/plugins/view-resources/src/components/ParentsNavigator.svelte b/plugins/view-resources/src/components/ParentsNavigator.svelte index b534514fa1..51f46a4898 100644 --- a/plugins/view-resources/src/components/ParentsNavigator.svelte +++ b/plugins/view-resources/src/components/ParentsNavigator.svelte @@ -22,8 +22,12 @@ const client = getClient() + function hasParent (doc: Doc | AttachedDoc): boolean { + return 'parent' in doc && doc.parent != null + } + async function getParents (doc: Doc | AttachedDoc): Promise { - if (!isAttachedDoc(doc)) { + if (!isAttachedDoc(doc) && !hasParent(doc)) { return [] } @@ -31,8 +35,10 @@ let currentDoc: Doc | undefined = doc - while (currentDoc && isAttachedDoc(currentDoc)) { - const parent: Doc | undefined = await client.findOne(currentDoc.attachedToClass, { _id: currentDoc.attachedTo }) + while (currentDoc && (isAttachedDoc(currentDoc) || hasParent(currentDoc))) { + const parent: Doc | undefined = isAttachedDoc(currentDoc) + ? await client.findOne(currentDoc.attachedToClass, { _id: currentDoc.attachedTo }) + : await client.findOne(currentDoc._class, { _id: (currentDoc as any).parent }) if (parent) { currentDoc = parent