aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/new_fields/Doc.ts23
-rw-r--r--src/new_fields/util.ts26
2 files changed, 12 insertions, 37 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index bc2d5c49e..b1c1fda05 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -179,12 +179,12 @@ 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(layoutKey, Doc);
- if (resolvedLayout instanceof Doc) {
- let layout = (resolvedLayout.layout as string).split("'")[1];
- return this[SelfProxy][layout + "-layout[" + resolvedLayout[Id] + "]"] || resolvedLayout;
+ public get [LayoutSym]() { return this[SelfProxy].__LAYOUT__; }
+ @computed get __LAYOUT__() {
+ const templateLayoutDoc = Cast(Doc.LayoutField(this[SelfProxy]), Doc, null);
+ if (templateLayoutDoc) {
+ const renderFieldKey = (templateLayoutDoc[StrCast(templateLayoutDoc.layoutKey, "layout")] as string).split("'")[1];
+ return Cast(this[SelfProxy][renderFieldKey + "-layout[" + templateLayoutDoc[Id] + "]"], Doc, null) || templateLayoutDoc;
}
return undefined;
}
@@ -691,16 +691,7 @@ 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 {
- 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 Layout(doc: Doc): Doc { return doc[LayoutSym] || 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")]; }
export function LayoutFieldKey(doc: Doc): string { return StrCast(Doc.Layout(doc).layout).split("'")[1]; }
diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts
index 52bb7afcd..ebc0a1272 100644
--- a/src/new_fields/util.ts
+++ b/src/new_fields/util.ts
@@ -104,8 +104,7 @@ let layoutProps = ["panX", "panY", "width", "height", "nativeWidth", "nativeHeig
"LODdisable", "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 !== "__LAYOUT__" && prop !== "__fields" &&
- ((prop as string).startsWith("_") || layoutProps.includes(prop))) {
+ if (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && (prop.startsWith("_") || layoutProps.includes(prop))) {
if (!prop.startsWith("_")) {
console.log(prop + " is deprecated - switch to _" + prop);
prop = "_" + prop;
@@ -114,36 +113,21 @@ export function setter(target: any, in_prop: string | symbol | number, value: an
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);
- // // 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 !== "__LAYOUT__" && prop !== "__fields" &&
- ((prop as string).startsWith("_") || layoutProps.includes(prop))) {
+ if (prop === LayoutSym) {
+ return target.__LAYOUT__;
+ }
+ if (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && (prop.startsWith("_") || layoutProps.includes(prop))) {
if (!prop.startsWith("_")) {
console.log(prop + " is deprecated - switch to _" + prop);
prop = "_" + 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)?.[prop];
- // //return resolvedLayout[prop];
- // }
}
if (prop === "then") {//If we're being awaited
return undefined;