diff options
| author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-04-09 02:45:06 -0400 |
|---|---|---|
| committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-04-09 02:45:06 -0400 |
| commit | cf86d1b7917f0317af550293344f784a341bd7b9 (patch) | |
| tree | 6a0ede46a4127812ebfecb2c9a8386a1de9fde61 /src/client/views | |
| parent | 5e086920bf97297a02bcd38faea56454c2220279 (diff) | |
Added script field and added list of scripts to list field
Diffstat (limited to 'src/client/views')
| -rw-r--r-- | src/client/views/collections/CollectionBaseView.tsx | 21 | ||||
| -rw-r--r-- | src/client/views/collections/CollectionSchemaView.tsx | 4 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/client/views/collections/CollectionBaseView.tsx b/src/client/views/collections/CollectionBaseView.tsx index 32462a4c1..4afa7cbf6 100644 --- a/src/client/views/collections/CollectionBaseView.tsx +++ b/src/client/views/collections/CollectionBaseView.tsx @@ -10,6 +10,8 @@ import { ListField } from '../../../fields/ListField'; import { action } from 'mobx'; import { Transform } from '../../util/Transform'; import { observer } from 'mobx-react'; +import { CompileScript } from '../../util/Scripting'; +import { ScriptField } from '../../../fields/ScriptField'; export enum CollectionViewType { Invalid, @@ -106,7 +108,24 @@ export class CollectionBaseView extends React.Component<CollectionViewProps> { } else { let proto = props.Document.GetPrototype(); if (!proto || proto === FieldWaiting || !this.createsCycle(proto, doc)) { - props.Document.SetOnPrototype(props.fieldKey, new ListField([doc])); + const field = new ListField([doc]); + // const script = CompileScript(` + // if(added) { + // console.log("added " + field.Title); + // } else { + // console.log("removed " + field.Title); + // } + // `, { + // addReturn: false, + // params: { + // field: Document.name, + // added: "boolean" + // } + // }); + // if (script.compiled) { + // field.addScript(new ScriptField(script)); + // } + props.Document.SetOnPrototype(props.fieldKey, field); } else { return false; diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index 52933818f..587f60b3d 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -121,14 +121,14 @@ export class CollectionSchemaView extends CollectionSubView { return field || ""; }} SetValue={(value: string) => { - let script = CompileScript(value, { addReturn: true, params: { this: "Document" } }); + let script = CompileScript(value, { addReturn: true, params: { this: Document.name } }); if (!script.compiled) { return false; } return applyToDoc(props.Document, script.run); }} OnFillDown={(value: string) => { - let script = CompileScript(value, { addReturn: true, params: { this: "Document" } }); + let script = CompileScript(value, { addReturn: true, params: { this: Document.name } }); if (!script.compiled) { return; } |
