diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2020-05-14 16:33:40 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2020-05-14 16:33:40 -0400 |
commit | f6a55c0d613787f60e4a40b728a1acbc6c39c552 (patch) | |
tree | 38121dcadfc8db9bb29ebf3168cb3acb6eaabdbf /src/new_fields/util.ts | |
parent | bfeb50130f9fff635fb317a0b4bc0b2d2590c5df (diff) |
added setter scripts for fields. fixed color selection
Diffstat (limited to 'src/new_fields/util.ts')
-rw-r--r-- | src/new_fields/util.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts index 8c719ccd8..a287b0210 100644 --- a/src/new_fields/util.ts +++ b/src/new_fields/util.ts @@ -7,6 +7,8 @@ import { ObjectField } from "./ObjectField"; import { action, trace } from "mobx"; import { Parent, OnUpdate, Update, Id, SelfProxy, Self } from "./FieldSymbols"; import { DocServer } from "../client/DocServer"; +import { ComputedField } from "./ScriptField"; +import { ScriptCast } from "./Types"; function _readOnlySetter(): never { throw new Error("Documents can't be modified in read-only mode"); @@ -114,6 +116,9 @@ export function setter(target: any, in_prop: string | symbol | number, value: an return true; } } + if (target.__fields[prop] instanceof ComputedField && target.__fields[prop].setterscript) { + return ScriptCast(target.__fields[prop])?.setterscript?.run({ self: target[SelfProxy], this: target[SelfProxy], value }).success ? true : false; + } return _setter(target, prop, value, receiver); } |