aboutsummaryrefslogtreecommitdiff
path: root/src/fields/util.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-03-21 18:58:21 -0400
committerbobzel <zzzman@gmail.com>2025-03-21 18:58:21 -0400
commit7e4d793eaa7e5b6b564355a11fa02a5611645f20 (patch)
treeacab0bf2057a26b4daeead8ce8d4568afa167b2a /src/fields/util.ts
parent2d64242ce924a5ba18e3c8dd0a6efe54db2e3f9a (diff)
trying to improve how data / layout / root and templtae docs are accessed.
Diffstat (limited to 'src/fields/util.ts')
-rw-r--r--src/fields/util.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/fields/util.ts b/src/fields/util.ts
index 33764aca5..abbe543e8 100644
--- a/src/fields/util.ts
+++ b/src/fields/util.ts
@@ -314,6 +314,13 @@ export function setter(target: ListImpl<FieldType> | Doc, inProp: string | symbo
// 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].includes(value as SharingPermissions))) return true;
+ if (typeof prop === 'string' && prop !== '__id' && prop !== '__fieldTuples' && prop.startsWith('$')) {
+ prop = prop.substring(1);
+ if (target.__DATA__ instanceof Doc) {
+ target.__DATA__[prop] = value as FieldResult;
+ return true;
+ }
+ }
if (typeof prop === 'string' && prop !== '__id' && prop !== '__fieldTuples' && prop.startsWith('_')) {
if (!prop.startsWith('__')) prop = prop.substring(1);
if (target.__LAYOUT__ instanceof Doc) {
@@ -351,6 +358,7 @@ export function getter(target: Doc | ListImpl<FieldType>, prop: string | symbol,
case DocAcl : return target[DocAcl];
case $mobx: return target.__fieldTuples[prop];
case DocLayout: return target.__LAYOUT__;
+ case DocData: return target.__DATA__;
case Height: case Width: if (GetEffectiveAcl(target) === AclPrivate) return returnZero;
// eslint-disable-next-line no-fallthrough
default :
@@ -362,6 +370,8 @@ export function getter(target: Doc | ListImpl<FieldType>, prop: string | symbol,
const layoutProp = prop.startsWith('_') ? prop.substring(1) : undefined;
if (layoutProp && target.__LAYOUT__) return (target.__LAYOUT__ as Doc)[layoutProp];
+ const dataProp = prop.startsWith('$') ? prop.substring(1) : undefined;
+ if (dataProp && target.__DATA__) return (target.__DATA__ as Doc)[dataProp];
return getFieldImpl(target, layoutProp ?? prop, proxy);
}