diff options
author | usodhi <61431818+usodhi@users.noreply.github.com> | 2021-03-02 23:35:15 -0500 |
---|---|---|
committer | usodhi <61431818+usodhi@users.noreply.github.com> | 2021-03-02 23:35:15 -0500 |
commit | 067377e138254c72ad4cf3609b05d5aab2b71a26 (patch) | |
tree | 9ce9b22e585a0e1472eb3216630c2404e8517144 /src/fields/util.ts | |
parent | 95451a2eb0871856b946fff8a14ca0c385af5f1b (diff) | |
parent | 1b481cd441cc8bb200906b246b43e4bc5dc53b4e (diff) |
agh stop merging
Diffstat (limited to 'src/fields/util.ts')
-rw-r--r-- | src/fields/util.ts | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/fields/util.ts b/src/fields/util.ts index b9c5a13c1..36c765dd0 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -280,16 +280,16 @@ export function setter(target: any, in_prop: string | symbol | number, value: an let prop = in_prop; const effectiveAcl = getPropAcl(target, prop); if (effectiveAcl !== AclEdit && effectiveAcl !== AclAdmin) return true; - // if you're trying to change an acl but don't have Admin access / you're trying to change it to something that isn't an acceptable acl, you can't if (typeof prop === "string" && prop.startsWith("acl") && (effectiveAcl !== AclAdmin || ![...Object.values(SharingPermissions), undefined, "None"].includes(value))) return true; // if (typeof prop === "string" && prop.startsWith("acl") && !["Can Edit", "Can Augment", "Can View", "Not Shared", undefined].includes(value)) return true; - 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 (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && prop.startsWith("_")) { + // if (!prop.startsWith("_")) { + // console.log(prop + " is deprecated - switch to _" + prop); + // prop = "_" + prop; + // } + if (!prop.startsWith("__")) prop = prop.substring(1); if (target.__LAYOUT__) { target.__LAYOUT__[prop] = value; return true; @@ -308,12 +308,14 @@ export function getter(target: any, in_prop: string | symbol | number, receiver: if (in_prop === "toString" || (in_prop !== HeightSym && in_prop !== WidthSym && in_prop !== LayoutSym && typeof prop === "symbol")) return target.__fields[prop] || target[prop]; if (GetEffectiveAcl(target) === AclPrivate) return prop === HeightSym || prop === WidthSym ? returnZero : undefined; 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]; + let search = false; + if (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && prop.startsWith("_")) { + // if (!prop.startsWith("_")) { + // console.log(prop + " is deprecated - switch to _" + prop); + // prop = "_" + prop; + // } + if (!prop.startsWith("__")) search = true; + if (target.__LAYOUT__) return target.__LAYOUT__[prop] ?? (search ? target.__LAYOUT__[prop.substring(1)] : undefined); } if (prop === "then") {//If we're being awaited return undefined; @@ -324,7 +326,7 @@ export function getter(target: any, in_prop: string | symbol | number, receiver: if (SerializationHelper.IsSerializing()) { return target[prop]; } - return getFieldImpl(target, prop, receiver); + return (search ? getFieldImpl(target, (prop as any as string).substring(1), receiver) : undefined) ?? getFieldImpl(target, prop, receiver); } function getFieldImpl(target: any, prop: string | number, receiver: any, ignoreProto: boolean = false): any { |