aboutsummaryrefslogtreecommitdiff
path: root/src/fields/util.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-04-10 14:06:59 -0400
committerbobzel <zzzman@gmail.com>2025-04-10 14:06:59 -0400
commitaff4fff58655ff48613b2519b55787955a766667 (patch)
tree589286f293737e60edc23b95b8ea63ff7e0b5d8b /src/fields/util.ts
parentb6823909532bdc727a51b8bda266cf62dd5dff6d (diff)
parent463cd15186a3463897d977bfa11af5c4929798ae (diff)
Merge branch 'master' into aarav_edit
Diffstat (limited to 'src/fields/util.ts')
-rw-r--r--src/fields/util.ts25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/fields/util.ts b/src/fields/util.ts
index abbe543e8..205c500a5 100644
--- a/src/fields/util.ts
+++ b/src/fields/util.ts
@@ -303,30 +303,23 @@ export function SetPropSetterCb(prop: string, propSetter: ((target: Doc, value:
//
// target should be either a Doc or ListImpl. receiver should be a Proxy<Doc> Or List.
//
-export function setter(target: ListImpl<FieldType> | Doc, inProp: string | symbol | number, value: unknown, receiver: Doc | ListImpl<FieldType>): boolean {
- if (!inProp) {
+export function setter(target: ListImpl<FieldType> | Doc, prop: string | symbol | number, value: unknown, receiver: Doc | ListImpl<FieldType>): boolean {
+ if (!prop) {
console.log('WARNING: trying to set an empty property. This should be fixed. ');
return false;
}
- let prop = inProp;
- const effectiveAcl = inProp === 'constructor' || typeof inProp === 'symbol' ? AclAdmin : GetPropAcl(target, prop);
+ const effectiveAcl = prop === 'constructor' || typeof prop === 'symbol' ? AclAdmin : GetPropAcl(target, prop);
if (effectiveAcl !== AclEdit && effectiveAcl !== AclAugment && 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].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 (target instanceof Doc && typeof prop === 'string' && prop !== '__id' && prop !== '__fieldTuples' && prop.startsWith('$')) {
+ target.__DATA__[prop.substring(1)] = 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) {
- target.__LAYOUT__[prop] = value as FieldResult;
- return true;
- }
+ if (target instanceof Doc && typeof prop === 'string' && prop !== '__id' && prop !== '__fieldTuples' && prop.startsWith('_') && !prop.startsWith('__')) {
+ target.__LAYOUT__[prop.substring(1)] = value as FieldResult;
+ return true;
}
if (target.__fieldTuples[prop] instanceof ComputedField) {
if (target.__fieldTuples[prop].setterscript && value !== undefined && !(value instanceof ComputedField)) {