feat: Nested document sharing (#2075)

* migration

* frontend routing, api permissioning

* feat: apiVersion=2

* feat: re-writing document links to point to share

* poc nested documents on share links

* fix: nested shareId permissions

* ui and language tweaks, comments

* breadcrumbs

* Add icons to reference list items

* refactor: Breadcrumb component

* tweaks

* Add shared parent note
This commit is contained in:
Tom Moor
2021-05-22 19:34:05 -07:00
committed by GitHub
parent dc4b5588b7
commit 44920a25f4
31 changed files with 1134 additions and 282 deletions

View File

@ -375,6 +375,77 @@ Collection.prototype.deleteDocument = async function (document) {
await document.deleteWithChildren();
};
Collection.prototype.isChildDocument = function (
parentDocumentId,
documentId
): boolean {
let result = false;
const loopChildren = (documents, input) => {
return documents.map((document) => {
let parents = [...input];
if (document.id === documentId) {
result = parents.includes(parentDocumentId);
} else {
parents.push(document.id);
loopChildren(document.children, parents);
}
return document;
});
};
loopChildren(this.documentStructure, []);
return result;
};
Collection.prototype.getDocumentTree = function (documentId: string) {
let result;
const loopChildren = (documents) => {
if (result) {
return;
}
documents.forEach((document) => {
if (result) {
return;
}
if (document.id === documentId) {
result = document;
} else {
loopChildren(document.children);
}
});
};
loopChildren(this.documentStructure);
return result;
};
Collection.prototype.getDocumentParents = function (
documentId: string
): string[] | void {
let result;
const loopChildren = (documents, path = []) => {
if (result) {
return;
}
documents.forEach((document) => {
if (document.id === documentId) {
result = path;
} else {
loopChildren(document.children, [...path, document.id]);
}
});
};
loopChildren(this.documentStructure);
return result;
};
Collection.prototype.removeDocumentInStructure = async function (
document,
options