aboutsummaryrefslogtreecommitdiff
path: root/src/fields/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/fields/util.ts')
-rw-r--r--src/fields/util.ts28
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 {