diff options
author | Andy Rickert <andrew_rickert@brown.edu> | 2020-04-02 17:42:18 -0700 |
---|---|---|
committer | Andy Rickert <andrew_rickert@brown.edu> | 2020-04-02 17:42:18 -0700 |
commit | fb329b1a8abca361d831c7ec1f1a9ea0f3d410cf (patch) | |
tree | e09138a0544fe3814b1bd1e95d59bc4c0e96f5ed /src/new_fields/util.ts | |
parent | 3a1dac48c00dbe81142da90f8b52bfae02ce1921 (diff) | |
parent | b4958eac84339dd7a88c964a9c52e89481048f55 (diff) |
merge
Diffstat (limited to 'src/new_fields/util.ts')
-rw-r--r-- | src/new_fields/util.ts | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts index 2cedda7a6..8c719ccd8 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"; @@ -7,14 +7,14 @@ import { ObjectField } from "./ObjectField"; import { action, trace } from "mobx"; import { Parent, OnUpdate, Update, Id, SelfProxy, Self } from "./FieldSymbols"; import { DocServer } from "../client/DocServer"; -import { props } from "bluebird"; function _readOnlySetter(): never { throw new Error("Documents can't be modified in read-only mode"); } +const tracing = false; export function TraceMobx() { - //trace(); + tracing && trace(); } export interface GetterResult { @@ -100,19 +100,17 @@ export function makeEditable() { _setter = _setterImpl; } -let layoutProps = ["panX", "panY", "width", "height", "nativeWidth", "nativeHeight", "fitWidth", "fitToBox", - "LODdisable", "dropAction", "chromeStatus", "viewType", "gridGap", "xMargin", "yMargin", "autoHeight"]; +const layoutProps = ["panX", "panY", "width", "height", "nativeWidth", "nativeHeight", "fitWidth", "fitToBox", + "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 !== "__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; } - const resolvedLayout = getFieldImpl(target, getFieldImpl(target, "layoutKey", receiver), receiver); - if (resolvedLayout instanceof Doc) { - resolvedLayout[prop] = value; + if (target.__LAYOUT__) { + target.__LAYOUT__[prop] = value; return true; } } @@ -121,16 +119,15 @@ export function setter(target: any, in_prop: string | symbol | number, value: an 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" && - ((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; } - const resolvedLayout = getFieldImpl(target, getFieldImpl(target, "layoutKey", receiver), receiver); - if (resolvedLayout instanceof Doc) { - return resolvedLayout[prop]; - } + if (target.__LAYOUT__) return target.__LAYOUT__[prop]; } if (prop === "then") {//If we're being awaited return undefined; |