aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/ScriptField.ts
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2020-02-25 12:45:33 -0500
committerbob <bcz@cs.brown.edu>2020-02-25 12:45:33 -0500
commitc5c8c99151de576548dab215b82d44132b06f9a4 (patch)
tree9c05f024525aefb8f47b7837bfd88339eed0eb2b /src/new_fields/ScriptField.ts
parent9399d2a44261ffce3f33cf1ea2dac032a8d3fdc8 (diff)
added inheritable computations to template fields
Diffstat (limited to 'src/new_fields/ScriptField.ts')
-rw-r--r--src/new_fields/ScriptField.ts2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/new_fields/ScriptField.ts b/src/new_fields/ScriptField.ts
index 4c78ea3aa..131e1f339 100644
--- a/src/new_fields/ScriptField.ts
+++ b/src/new_fields/ScriptField.ts
@@ -130,7 +130,7 @@ export class ScriptField extends ObjectField {
export class ComputedField extends ScriptField {
_lastComputedResult: any;
//TODO maybe add an observable cache based on what is passed in for doc, considering there shouldn't really be that many possible values for doc
- value = computedFn((doc: Doc) => this._lastComputedResult = this.script.run({ this: doc, _last_: this._lastComputedResult }, console.log).result);
+ value = computedFn((doc: Doc) => this._lastComputedResult = this.script.run({ source: doc.expandedTemplate || doc, this: doc, _last_: this._lastComputedResult }, console.log).result);
public static MakeScript(script: string, params: object = {}) {
const compiled = ScriptField.CompileScript(script, params, false);
return compiled.compiled ? new ComputedField(compiled) : undefined;