diff options
author | bobzel <zzzman@gmail.com> | 2023-01-13 10:04:53 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-01-13 10:04:53 -0500 |
commit | 603d3c0d500fd14dd732040d588fec0e91768729 (patch) | |
tree | 497e4e30cfe544ab45d912609e44f13e24be8a99 /src/fields/Doc.ts | |
parent | bb185ceffcac42af373faf40e0bc2225150c243d (diff) |
cleaned up linkmanager a little. maded myshareddocs a folder in myfilesystem. fixed setting author on copied documents to current user.
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r-- | src/fields/Doc.ts | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index 19ffc5005..df49c32f0 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -239,6 +239,19 @@ export class Doc extends RefField { public static get MyFileOrphans() { return DocCast(Doc.UserDoc().myFileOrphans); } + public static AddFileOrphan(doc: Doc) { + if ( + doc && + Doc.MyFileOrphans instanceof Doc && + Doc.IsPrototype(doc) && + !Doc.IsSystem(doc) && + ![DocumentType.MARKER, DocumentType.KVP, DocumentType.LINK, DocumentType.LINKANCHOR].includes(doc.type as any) && + !doc.isFolder && + !doc.annotationOn + ) { + Doc.AddDocToList(Doc.MyFileOrphans, undefined, doc); + } + } public static get MyTools() { return DocCast(Doc.UserDoc().myTools); } @@ -774,7 +787,7 @@ export namespace Doc { } cloneMap.set(doc[Id], copy); } - Doc.IsPrototype(copy) && Doc.AddDocToList(Doc.MyFileOrphans, undefined, copy); + Doc.AddFileOrphan(copy); return copy; } export async function MakeClone(doc: Doc, dontCreate: boolean = false, asBranch = false, cloneMap: Map<string, Doc> = new Map()) { @@ -958,7 +971,7 @@ export namespace Doc { Object.keys(doc).forEach(key => { if (exclude.includes(key)) return; const cfield = ComputedField.WithoutComputed(() => FieldValue(doc[key])); - const field = ProxyField.WithoutProxy(() => doc[key]); + const field = key === 'author' ? Doc.CurrentUserEmail : ProxyField.WithoutProxy(() => doc[key]); if (key === 'proto' && copyProto) { if (doc[key] instanceof Doc) { copy[key] = Doc.MakeCopy(doc[key]!, false); @@ -982,7 +995,6 @@ export namespace Doc { } } }); - copy.author = Doc.CurrentUserEmail; if (copyProto) { Doc.GetProto(copy).context = undefined; Doc.GetProto(copy).aliases = new List<Doc>([copy]); @@ -994,7 +1006,7 @@ export namespace Doc { if (retitle) { copy.title = incrementTitleCopy(StrCast(copy.title)); } - Doc.IsPrototype(copy) && Doc.AddDocToList(Doc.MyFileOrphans, undefined, copy); + Doc.AddFileOrphan(copy); return copy; } @@ -1013,6 +1025,7 @@ export namespace Doc { if (!Doc.IsSystem(doc)) Doc.AddDocToList(doc[DataSym], 'aliases', delegate); title && (delegate.title = title); delegate[Initializing] = false; + Doc.AddFileOrphan(delegate); return delegate; } return undefined; |