From 92a5efa6876db1a497640aeb13fef5c8d99b102d Mon Sep 17 00:00:00 2001 From: bob Date: Tue, 4 Feb 2020 10:38:14 -0500 Subject: fixing layout stuff --- src/client/views/MetadataEntryMenu.tsx | 18 +-------- src/client/views/TemplateMenu.tsx | 18 ++++----- .../views/collections/CollectionTimeView.tsx | 2 +- .../collectionFreeForm/CollectionFreeFormView.tsx | 15 +++---- src/new_fields/Doc.ts | 14 ++++++- src/new_fields/util.ts | 46 ++++++++++++---------- 6 files changed, 58 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/client/views/MetadataEntryMenu.tsx b/src/client/views/MetadataEntryMenu.tsx index 23b21ae0c..ac152bf67 100644 --- a/src/client/views/MetadataEntryMenu.tsx +++ b/src/client/views/MetadataEntryMenu.tsx @@ -133,23 +133,7 @@ export class MetadataEntryMenu extends React.Component{ } getKeySuggestions = async (value: string): Promise => { - value = value.toLowerCase(); - let docs = this.props.docs; - if (typeof docs === "function") { - if (this.props.suggestWithFunction) { - docs = docs(); - } else { - return []; - } - } - docs = await docs; - if (docs instanceof Doc) { - return Object.keys(docs).filter(key => key.toLowerCase().startsWith(value)); - } else { - const keys = new Set(); - docs.forEach(doc => Doc.allKeys(doc).forEach(key => keys.add(key))); - return Array.from(keys).filter(key => key.toLowerCase().startsWith(value)); - } + return []; } getSuggestionValue = (suggestion: string) => suggestion; diff --git a/src/client/views/TemplateMenu.tsx b/src/client/views/TemplateMenu.tsx index f61eb9cd0..9b0199eac 100644 --- a/src/client/views/TemplateMenu.tsx +++ b/src/client/views/TemplateMenu.tsx @@ -94,15 +94,15 @@ export class TemplateMenu extends React.Component { } } componentDidMount() { - !this._addedKeys && (this._addedKeys = new ObservableSet()); - Array.from(Object.keys(Doc.GetProto(this.props.docViews[0].props.Document))). - filter(key => key.startsWith("layout_")). - map(key => runInAction(() => this._addedKeys.add(key.replace("layout_", "")))); - DocListCast(Cast(CurrentUserUtils.UserDocument.expandingButtons, Doc, null)?.data)?.map(btnDoc => { - if (StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title)) { - runInAction(() => this._addedKeys.add(StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title))); - } - }); + // !this._addedKeys && (this._addedKeys = new ObservableSet()); + // Array.from(Object.keys(Doc.GetProto(this.props.docViews[0].props.Document))). + // filter(key => key.startsWith("layout_")). + // map(key => runInAction(() => this._addedKeys.add(key.replace("layout_", "")))); + // DocListCast(Cast(CurrentUserUtils.UserDocument.expandingButtons, Doc, null)?.data)?.map(btnDoc => { + // if (StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title)) { + // runInAction(() => this._addedKeys.add(StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title))); + // } + // }); } _addedKeys = new ObservableSet(); diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx index 253dfa890..d1e2844df 100644 --- a/src/client/views/collections/CollectionTimeView.tsx +++ b/src/client/views/collections/CollectionTimeView.tsx @@ -43,7 +43,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) { @computed get _allFacets() { const facets = new Set(); - this.childDocs.forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key))); + //this.childDocs.forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key))); return facets.toArray(); } diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 6453cfe17..63544a637 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -824,13 +824,14 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) { } get doLayoutComputation() { const { newPool, computedElementData } = this.doInternalLayoutComputation; - Array.from(newPool.keys()).map(key => { - const lastPos = this._cachedPool.get(key); // last computed pos - const newPos = newPool.get(key); - if (!lastPos || newPos.x !== lastPos.x || newPos.y !== lastPos.y || newPos.z !== lastPos.z || newPos.zIndex !== lastPos.zIndex || newPos.width !== lastPos.width || newPos.height !== lastPos.height) { - runInAction(() => this._layoutPoolData.set(key, { transition: "transform 1s", ...newPos })); - } - }); + runInAction(() => + Array.from(newPool.keys()).map(key => { + const lastPos = this._cachedPool.get(key); // last computed pos + const newPos = newPool.get(key); + if (!lastPos || newPos.x !== lastPos.x || newPos.y !== lastPos.y || newPos.z !== lastPos.z || newPos.zIndex !== lastPos.zIndex || newPos.width !== lastPos.width || newPos.height !== lastPos.height) { + this._layoutPoolData.set(key, newPos); + } + })); this._cachedPool.clear(); Array.from(newPool.keys()).forEach(k => this._cachedPool.set(k, newPool.get(k))); this.childLayoutPairs.filter((pair, i) => this.isCurrent(pair.layout)).forEach(pair => diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 4dcdc6581..7033b23f1 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -1,4 +1,4 @@ -import { observable, ObservableMap, runInAction, action } from "mobx"; +import { observable, ObservableMap, runInAction, action, computed } from "mobx"; import { alias, map, serializable } from "serializr"; import { DocServer } from "../client/DocServer"; import { DocumentType } from "../client/documents/DocumentTypes"; @@ -89,6 +89,7 @@ export function DocListCast(field: FieldResult): Doc[] { export const WidthSym = Symbol("Width"); export const HeightSym = Symbol("Height"); export const DataSym = Symbol("Data"); +export const LayoutSym = Symbol("Layout"); export const UpdatingFromServer = Symbol("UpdatingFromServer"); const CachedUpdates = Symbol("Cached updates"); @@ -167,6 +168,17 @@ export class Doc extends RefField { public [WidthSym] = () => NumCast(this[SelfProxy]._width); public [HeightSym] = () => NumCast(this[SelfProxy]._height); public get [DataSym]() { return Cast(this[SelfProxy].resolvedDataDoc, Doc, null) || this[SelfProxy]; } + @computed public get __LAYOUT__() { + const layoutKey = StrCast(this[SelfProxy].layoutKey); + const resolvedLayout = Cast(this[SelfProxy][layoutKey], Doc); + if (resolvedLayout instanceof Doc) { + let x = resolvedLayout[Id]; + let layout = (resolvedLayout.layout as string).split("'")[1]; + const layoutDoc = this[SelfProxy][layout + "-layout[" + x + "]"]; + return layoutDoc || this[SelfProxy]; + } + return undefined; + } [ToScriptString]() { return "invalid"; diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts index 3495a934d..1641ecc8a 100644 --- a/src/new_fields/util.ts +++ b/src/new_fields/util.ts @@ -1,5 +1,5 @@ import { UndoManager } from "../client/util/UndoManager"; -import { Doc, Field, FieldResult, UpdatingFromServer } from "./Doc"; +import { Doc, Field, FieldResult, UpdatingFromServer, LayoutSym } from "./Doc"; import { SerializationHelper } from "../client/util/SerializationHelper"; import { ProxyField, PrefetchProxy } from "./Proxy"; import { RefField } from "./RefField"; @@ -104,41 +104,47 @@ let layoutProps = ["panX", "panY", "width", "height", "nativeWidth", "nativeHeig "LODdisable", "dropAction", "chromeStatus", "viewType", "gridGap", "xMargin", "yMargin", "autoHeight"]; export function setter(target: any, in_prop: string | symbol | number, value: any, receiver: any): boolean { let prop = in_prop; - if (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && + if (typeof prop === "string" && prop !== "__id" && prop !== "__LAYOUT__" && prop !== "__fields" && ((prop as string).startsWith("_") || layoutProps.includes(prop))) { if (!prop.startsWith("_")) { console.log(prop + " is deprecated - switch to _" + prop); prop = "_" + prop; } - const resolvedLayout = getFieldImpl(target, getFieldImpl(target, "layoutKey", receiver), receiver); - if (resolvedLayout instanceof Doc) { - let x = resolvedLayout[Id]; - let layout = (resolvedLayout.layout as string).split("'")[1]; - let expanded = getFieldImpl(target, layout + "-layout[" + x + "]", receiver); - expanded && (expanded[prop] = value); - // resolvedLayout[prop] = value; - return true; - } + const self = target[Self]; + const layoutDoc = (self || target).__LAYOUT__; + if (layoutDoc) layoutDoc[prop] = value; + // const resolvedLayout = getFieldImpl(target, getFieldImpl(target, "layoutKey", receiver), receiver); + // if (resolvedLayout instanceof Doc) { + // let x = resolvedLayout[Id]; + // let layout = (resolvedLayout.layout as string).split("'")[1]; + // let expanded = getFieldImpl(target, layout + "-layout[" + x + "]", receiver); + // expanded && (expanded[prop] = value); + // // resolvedLayout[prop] = value; + // return true; + // } } return _setter(target, prop, value, receiver); } export function getter(target: any, in_prop: string | symbol | number, receiver: any): any { let prop = in_prop; - if (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && + if (typeof prop === "string" && prop !== "__id" && prop !== "__LAYOUT__" && prop !== "__fields" && ((prop as string).startsWith("_") || layoutProps.includes(prop))) { if (!prop.startsWith("_")) { console.log(prop + " is deprecated - switch to _" + prop); prop = "_" + prop; } - const resolvedLayout = getFieldImpl(target, getFieldImpl(target, "layoutKey", receiver), receiver); - if (resolvedLayout instanceof Doc) { - let x = resolvedLayout[Id]; - let layout = (resolvedLayout.layout as string).split("'")[1]; - let expanded = getFieldImpl(target, layout + "-layout[" + x + "]", receiver); - return (expanded || resolvedLayout)?.[prop]; - //return resolvedLayout[prop]; - } + const self = target[Self]; + const layoutDoc = (self || target).__LAYOUT__; + if (layoutDoc) return layoutDoc[prop]; + // const resolvedLayout = getFieldImpl(target, getFieldImpl(target, "layoutKey", receiver), receiver); + // if (resolvedLayout instanceof Doc) { + // let x = resolvedLayout[Id]; + // let layout = (resolvedLayout.layout as string).split("'")[1]; + // let expanded = getFieldImpl(target, layout + "-layout[" + x + "]", receiver); + // return (expanded || resolvedLayout)?.[prop]; + // //return resolvedLayout[prop]; + // } } if (prop === "then") {//If we're being awaited return undefined; -- cgit v1.2.3-70-g09d2 From ccedb9302632fcdbc75292b90942a34b98bebcee Mon Sep 17 00:00:00 2001 From: bob Date: Fri, 7 Feb 2020 13:58:24 -0500 Subject: restored things that cause problems. --- src/client/views/MetadataEntryMenu.tsx | 18 +++++++++++++++++- src/client/views/TemplateMenu.tsx | 18 +++++++++--------- src/client/views/collections/CollectionTimeView.tsx | 2 +- 3 files changed, 27 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/client/views/MetadataEntryMenu.tsx b/src/client/views/MetadataEntryMenu.tsx index ac152bf67..23b21ae0c 100644 --- a/src/client/views/MetadataEntryMenu.tsx +++ b/src/client/views/MetadataEntryMenu.tsx @@ -133,7 +133,23 @@ export class MetadataEntryMenu extends React.Component{ } getKeySuggestions = async (value: string): Promise => { - return []; + value = value.toLowerCase(); + let docs = this.props.docs; + if (typeof docs === "function") { + if (this.props.suggestWithFunction) { + docs = docs(); + } else { + return []; + } + } + docs = await docs; + if (docs instanceof Doc) { + return Object.keys(docs).filter(key => key.toLowerCase().startsWith(value)); + } else { + const keys = new Set(); + docs.forEach(doc => Doc.allKeys(doc).forEach(key => keys.add(key))); + return Array.from(keys).filter(key => key.toLowerCase().startsWith(value)); + } } getSuggestionValue = (suggestion: string) => suggestion; diff --git a/src/client/views/TemplateMenu.tsx b/src/client/views/TemplateMenu.tsx index 9b0199eac..f61eb9cd0 100644 --- a/src/client/views/TemplateMenu.tsx +++ b/src/client/views/TemplateMenu.tsx @@ -94,15 +94,15 @@ export class TemplateMenu extends React.Component { } } componentDidMount() { - // !this._addedKeys && (this._addedKeys = new ObservableSet()); - // Array.from(Object.keys(Doc.GetProto(this.props.docViews[0].props.Document))). - // filter(key => key.startsWith("layout_")). - // map(key => runInAction(() => this._addedKeys.add(key.replace("layout_", "")))); - // DocListCast(Cast(CurrentUserUtils.UserDocument.expandingButtons, Doc, null)?.data)?.map(btnDoc => { - // if (StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title)) { - // runInAction(() => this._addedKeys.add(StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title))); - // } - // }); + !this._addedKeys && (this._addedKeys = new ObservableSet()); + Array.from(Object.keys(Doc.GetProto(this.props.docViews[0].props.Document))). + filter(key => key.startsWith("layout_")). + map(key => runInAction(() => this._addedKeys.add(key.replace("layout_", "")))); + DocListCast(Cast(CurrentUserUtils.UserDocument.expandingButtons, Doc, null)?.data)?.map(btnDoc => { + if (StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title)) { + runInAction(() => this._addedKeys.add(StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title))); + } + }); } _addedKeys = new ObservableSet(); diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx index d1e2844df..253dfa890 100644 --- a/src/client/views/collections/CollectionTimeView.tsx +++ b/src/client/views/collections/CollectionTimeView.tsx @@ -43,7 +43,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) { @computed get _allFacets() { const facets = new Set(); - //this.childDocs.forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key))); + this.childDocs.forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key))); return facets.toArray(); } -- cgit v1.2.3-70-g09d2 From d310058e80f0896e2724f8723d5b95e1077296c1 Mon Sep 17 00:00:00 2001 From: bob Date: Fri, 7 Feb 2020 15:06:46 -0500 Subject: fixed __LAYOUT__ and added action() to pivot-in action --- src/client/views/collections/CollectionTimeView.tsx | 10 ++++++---- src/new_fields/Doc.ts | 15 +++++++++++---- src/new_fields/util.ts | 15 +++++++-------- 3 files changed, 24 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx index 0c1f93829..4983acbc2 100644 --- a/src/client/views/collections/CollectionTimeView.tsx +++ b/src/client/views/collections/CollectionTimeView.tsx @@ -1,6 +1,6 @@ import { faEdit } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { action, computed, observable, trace } from "mobx"; +import { action, computed, observable, trace, runInAction } from "mobx"; import { observer } from "mobx-react"; import { Set } from "typescript-collections"; import { Doc, DocListCast, Field } from "../../../new_fields/Doc"; @@ -323,7 +323,9 @@ Scripting.addGlobal(function pivotColumnClick(pivotDoc: Doc, bounds: ViewDefBoun let pfilterIndex = NumCast(pivotDoc._pfilterIndex); pivotDoc["_pfilter" + pfilterIndex] = ObjectField.MakeCopy(pivotDoc._docFilter as ObjectField); pivotDoc._pfilterIndex = ++pfilterIndex; - pivotDoc._docFilter = new List(); - (bounds.payload as string[]).map(filterVal => - Doc.setDocFilter(pivotDoc, StrCast(pivotDoc._pivotField), filterVal, "check")); + runInAction(() => { + pivotDoc._docFilter = new List(); + (bounds.payload as string[]).map(filterVal => + Doc.setDocFilter(pivotDoc, StrCast(pivotDoc._pivotField), filterVal, "check")); + }); }); \ No newline at end of file diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 69717e612..3abd6aaa4 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -112,8 +112,11 @@ export class Doc extends RefField { get: getter, // getPrototypeOf: (target) => Cast(target[SelfProxy].proto, Doc) || null, // TODO this might be able to replace the proto logic in getter has: (target, key) => key in target.__fields, - ownKeys: target => Object.keys(target.__fields), + ownKeys: target => Object.keys(target.__allfields), getOwnPropertyDescriptor: (target, prop) => { + if (prop.toString() === "__LAYOUT__") { + return Reflect.getOwnPropertyDescriptor(target, prop); + } if (prop in target.__fields) { return { configurable: true,//TODO Should configurable be true? @@ -140,6 +143,12 @@ export class Doc extends RefField { private get __fields() { return this.___fields; } + private get __allfields() { + let obj = this.___fields; + obj.__LAYOUT__ = this.__LAYOUT__; + return obj; + } + private set __fields(value) { this.___fields = value; @@ -173,10 +182,8 @@ export class Doc extends RefField { const layoutKey = StrCast(this[SelfProxy].layoutKey); const resolvedLayout = Cast(this[SelfProxy][layoutKey], Doc); if (resolvedLayout instanceof Doc) { - let x = resolvedLayout[Id]; let layout = (resolvedLayout.layout as string).split("'")[1]; - const layoutDoc = this[SelfProxy][layout + "-layout[" + x + "]"]; - return layoutDoc || this[SelfProxy]; + return this[SelfProxy][layout + "-layout[" + resolvedLayout[Id] + "]"]; } return undefined; } diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts index 26c10525e..52bb7afcd 100644 --- a/src/new_fields/util.ts +++ b/src/new_fields/util.ts @@ -110,15 +110,16 @@ export function setter(target: any, in_prop: string | symbol | number, value: an console.log(prop + " is deprecated - switch to _" + prop); prop = "_" + prop; } - const self = target[Self]; - const layoutDoc = (self || target).__LAYOUT__; - if (layoutDoc) layoutDoc[prop] = value; + if (target.__LAYOUT__) { + target.__LAYOUT__[prop] = value; + return true; + } // const resolvedLayout = getFieldImpl(target, getFieldImpl(target, "layoutKey", receiver), receiver); // if (resolvedLayout instanceof Doc) { // let x = resolvedLayout[Id]; // let layout = (resolvedLayout.layout as string).split("'")[1]; // let expanded = getFieldImpl(target, layout + "-layout[" + x + "]", receiver); - // expanded && (expanded[prop] = value); + // //expanded && (expanded[prop] = value); // // resolvedLayout[prop] = value; // return true; // } @@ -134,15 +135,13 @@ export function getter(target: any, in_prop: string | symbol | number, receiver: console.log(prop + " is deprecated - switch to _" + prop); prop = "_" + prop; } - const self = target[Self]; - const layoutDoc = (self || target).__LAYOUT__; - if (layoutDoc) return layoutDoc[prop]; + if (target.__LAYOUT__) return target.__LAYOUT__[prop]; // const resolvedLayout = getFieldImpl(target, getFieldImpl(target, "layoutKey", receiver), receiver); // if (resolvedLayout instanceof Doc) { // let x = resolvedLayout[Id]; // let layout = (resolvedLayout.layout as string).split("'")[1]; // let expanded = getFieldImpl(target, layout + "-layout[" + x + "]", receiver); - // return (expanded || resolvedLayout)?.[prop]; + // return (expanded)?.[prop]; // //return resolvedLayout[prop]; // } } -- cgit v1.2.3-70-g09d2 From 10476052270245c9f57979487336af40fb24139f Mon Sep 17 00:00:00 2001 From: bob Date: Fri, 7 Feb 2020 15:17:06 -0500 Subject: fixed imageresize issue --- src/client/views/nodes/ImageBox.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index 1951fcc1a..896ac1685 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -257,7 +257,7 @@ export class ImageBox extends DocAnnotatableComponent console.log(err)); - } else if (this.Document._nativeHeight !== cachedNativeSize.width || this.Document._nativeWidth !== cachedNativeSize.height) { + } else if (this.Document._nativeWidth !== cachedNativeSize.width || this.Document._nativeHeight !== cachedNativeSize.height) { !(this.Document[StrCast(this.props.Document.layoutKey)] instanceof Doc) && setTimeout(() => { if (!(this.Document[StrCast(this.props.Document.layoutKey)] instanceof Doc)) { this.Document._nativeWidth = cachedNativeSize.width; -- cgit v1.2.3-70-g09d2 From f028edcf9611d4311e1e8454a41b91667f2dc7ba Mon Sep 17 00:00:00 2001 From: bob Date: Fri, 7 Feb 2020 15:42:16 -0500 Subject: more performance tweaks... --- src/new_fields/Doc.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 3abd6aaa4..bc2d5c49e 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -144,8 +144,9 @@ export class Doc extends RefField { return this.___fields; } private get __allfields() { - let obj = this.___fields; - obj.__LAYOUT__ = this.__LAYOUT__; + let obj = {} as any; + Object.assign(obj, this.___fields); + runInAction(() => obj.__LAYOUT__ = this.__LAYOUT__); return obj; } @@ -180,10 +181,10 @@ export class Doc extends RefField { public get [DataSym]() { return Cast(this[SelfProxy].resolvedDataDoc, Doc, null) || this[SelfProxy]; } @computed public get __LAYOUT__() { const layoutKey = StrCast(this[SelfProxy].layoutKey); - const resolvedLayout = Cast(this[SelfProxy][layoutKey], Doc); + const resolvedLayout = Cast(layoutKey, Doc); if (resolvedLayout instanceof Doc) { let layout = (resolvedLayout.layout as string).split("'")[1]; - return this[SelfProxy][layout + "-layout[" + resolvedLayout[Id] + "]"]; + return this[SelfProxy][layout + "-layout[" + resolvedLayout[Id] + "]"] || resolvedLayout; } return undefined; } @@ -691,12 +692,14 @@ export namespace Doc { // the document containing the view layout information - will be the Document itself unless the Document has // a layout field. In that case, all layout information comes from there unless overriden by Document export function Layout(doc: Doc): Doc { - let templateLayoutDoc = Cast(Doc.LayoutField(doc), Doc, null); - if (templateLayoutDoc) { - const renderFieldKey = Doc.LayoutFieldKey(templateLayoutDoc); - return Cast(doc[renderFieldKey + "-layout[" + templateLayoutDoc[Id] + "]"], Doc, null) || templateLayoutDoc; - } - return doc; + return doc.__LAYOUT__ || Cast(Doc.LayoutField(doc), Doc, null) || doc; + // let templateLayoutDoc = Cast(Doc.LayoutField(doc), Doc, null); + // if (templateLayoutDoc) { + // const renderFieldKey = Doc.LayoutFieldKey(templateLayoutDoc); + // const layout = Cast(doc[renderFieldKey + "-layout[" + templateLayoutDoc[Id] + "]"], Doc, null) || templateLayoutDoc; + // return layout; + // } + // return doc; } export function SetLayout(doc: Doc, layout: Doc | string) { doc[StrCast(doc.layoutKey, "layout")] = layout; } export function LayoutField(doc: Doc) { return doc[StrCast(doc.layoutKey, "layout")]; } -- cgit v1.2.3-70-g09d2