diff options
| author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-04-07 01:14:31 -0400 |
|---|---|---|
| committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-04-07 01:14:31 -0400 |
| commit | 44aa6fe49de97998fd84a6d6331501c8a1d7a775 (patch) | |
| tree | 4195eea591c0f7a625262b0b14674df9488db662 /src/client/views/collections/CollectionSchemaView.tsx | |
| parent | cb368c2553237bf336be921e9ad2a1aabf22dd90 (diff) | |
Refactored scripting to seperate compilation and execution
Diffstat (limited to 'src/client/views/collections/CollectionSchemaView.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionSchemaView.tsx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index 0ff6c3b40..afe530c1a 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -87,11 +87,13 @@ export class CollectionSchemaView extends CollectionViewBase { let reference = React.createRef<HTMLDivElement>(); let onItemDown = setupDrag(reference, () => props.doc, (containingCollection: CollectionView) => this.props.removeDocument(props.doc)); let applyToDoc = (doc: Document, value: string) => { - let script = CompileScript(value, { this: doc }, true); + let script = CompileScript(value, { addReturn: true, params: { this: "Document" } }); if (!script.compiled) { return false; } - let field = script(); + const res = script.run({ this: doc }); + if (!res.success) return false; + const field = res.result; if (field instanceof Field) { doc.Set(props.fieldKey, field); return true; @@ -121,6 +123,7 @@ export class CollectionSchemaView extends CollectionViewBase { return applyToDoc(props.doc, value); }} OnFillDown={(value: string) => { + //TODO This should be able to be refactored to compile the script once this.props.Document.GetTAsync<ListField<Document>>(this.props.fieldKey, ListField).then((val) => { if (val) { val.Data.forEach(doc => applyToDoc(doc, value)); |
