feat: Allow moving draft documents (#4652)

* feat: Allow moving draft documents

* Allow drag-n-drop move of draft documents

* fix: Allow moving draft without a collection

* fix: Allow moving draft without a collection
This commit is contained in:
Tom Moor
2023-01-06 19:31:06 -08:00
committed by GitHub
parent 9f825b9adf
commit e67ac1215a
8 changed files with 61 additions and 63 deletions

View File

@@ -171,8 +171,11 @@ export default class Collection extends ParanoidModel {
}
pathToDocument(documentId: string) {
let path: NavigationNode[] | undefined;
let path: NavigationNode[] | undefined = [];
const document = this.store.rootStore.documents.get(documentId);
if (!document) {
return path;
}
const travelNodes = (
nodes: NavigationNode[],
@@ -187,8 +190,8 @@ export default class Collection extends ParanoidModel {
}
if (
document?.parentDocumentId &&
node?.id === document?.parentDocumentId
document.parentDocumentId &&
node.id === document.parentDocumentId
) {
path = [...newPath, document.asNavigationNode];
return;
@@ -199,10 +202,10 @@ export default class Collection extends ParanoidModel {
};
if (this.documents) {
travelNodes(this.documents, []);
travelNodes(this.documents, path);
}
return path || [];
return path;
}
@action