From 162cea3ee2167a6d999b99630c33edb3779c7bcc Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 22 Jan 2020 18:38:07 -0500 Subject: added an exclude list of field keys when a document is copied --- src/client/views/collections/CollectionPivotView.tsx | 2 +- src/new_fields/Doc.ts | 3 ++- src/new_fields/documentSchemas.ts | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionPivotView.tsx b/src/client/views/collections/CollectionPivotView.tsx index aa68cc18f..43a302af7 100644 --- a/src/client/views/collections/CollectionPivotView.tsx +++ b/src/client/views/collections/CollectionPivotView.tsx @@ -28,7 +28,7 @@ export class CollectionPivotView extends CollectionSubView(doc => doc) { if (!this.props.Document.facetCollection) { const facetCollection = Docs.Create.TreeDocument([], { title: "facetFilters", yMargin: 0, treeViewHideTitle: true }); facetCollection.target = this.props.Document; - facetCollection.dontCopyOnAlias = true; + this.props.Document.excludeFields = new List(["facetCollection", "docFilter", "viewSpecScript"]); const scriptText = "setDocFilter(containingTreeView.target, heading, this.title, checked)"; const script = CompileScript(scriptText, { diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index ae6031ee9..e9f8e6429 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -535,7 +535,9 @@ export namespace Doc { export function MakeCopy(doc: Doc, copyProto: boolean = false, copyProtoId?: string): Doc { const copy = new Doc(copyProtoId, true); + const exclude = Cast(doc.excludeFields, listSpec("string"), []); Object.keys(doc).forEach(key => { + if (exclude.includes(key)) return; const cfield = ComputedField.WithoutComputed(() => FieldValue(doc[key])); const field = ProxyField.WithoutProxy(() => doc[key]); if (key === "proto" && copyProto) { @@ -547,7 +549,6 @@ export namespace Doc { copy[key] = field; } else if (cfield instanceof ComputedField) { copy[key] = ComputedField.MakeFunction(cfield.script.originalScript); - } else if (doc[key] instanceof Doc && (doc[key] as Doc).dontCopyOnAlias) { } else if (field instanceof ObjectField) { copy[key] = ObjectField.MakeCopy(field); } else if (field instanceof Promise) { diff --git a/src/new_fields/documentSchemas.ts b/src/new_fields/documentSchemas.ts index 3b641fc8e..3683e5820 100644 --- a/src/new_fields/documentSchemas.ts +++ b/src/new_fields/documentSchemas.ts @@ -18,7 +18,6 @@ export const documentSchema = createSchema({ creationDate: DateField, // when the document was created links: listSpec(Doc), // computed (readonly) list of links associated with this document dropAction: "string", // override specifying what should happen when this document is dropped (can be "alias" or "copy") - dontCopyOnAlias: "boolean", // whether the document should not be copied when it is a field of a document that is being aliased removeDropProperties: listSpec("string"), // properties that should be removed from the alias/copy/etc of this document when it is dropped onClick: ScriptField, // script to run when document is clicked (can be overriden by an onClick prop) onPointerDown: ScriptField, // script to run when document is clicked (can be overriden by an onClick prop) -- cgit v1.2.3-70-g09d2