From 9955ff8c2de58cfe37e02d6a356b5a8a2930bb05 Mon Sep 17 00:00:00 2001
From: bob <bcz@cs.brown.edu>
Date: Mon, 13 Jan 2020 13:29:18 -0500
Subject: fixed some scripting and added some functions for adding docFilters
 to collections

---
 src/client/views/ScriptBox.tsx | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

(limited to 'src/client/views/ScriptBox.tsx')

diff --git a/src/client/views/ScriptBox.tsx b/src/client/views/ScriptBox.tsx
index ded2329b4..d24256886 100644
--- a/src/client/views/ScriptBox.tsx
+++ b/src/client/views/ScriptBox.tsx
@@ -82,28 +82,19 @@ export class ScriptBox extends React.Component<ScriptBoxProps> {
         );
     }
     //let l = docList(this.source[0].data).length; if (l) { let ind = this.target[0].index !== undefined ? (this.target[0].index+1) % l : 0;  this.target[0].index = ind;  this.target[0].proto = getProto(docList(this.source[0].data)[ind]);}
-    public static EditButtonScript(title: string, doc: Doc, fieldKey: string, clientX: number, clientY: number, prewrapper?: string, postwrapper?: string) {
+    public static EditButtonScript(title: string, doc: Doc, fieldKey: string, clientX: number, clientY: number, contextParams?: { [name: string]: string }) {
         let overlayDisposer: () => void = emptyFunction;
         const script = ScriptCast(doc[fieldKey]);
         let originalText: string | undefined = undefined;
         if (script) {
             originalText = script.script.originalScript;
-            if (prewrapper && originalText.startsWith(prewrapper)) {
-                originalText = originalText.substr(prewrapper.length);
-            }
-            if (postwrapper && originalText.endsWith(postwrapper)) {
-                originalText = originalText.substr(0, originalText.length - postwrapper.length);
-            }
         }
         // tslint:disable-next-line: no-unnecessary-callback-wrapper
         const params: string[] = [];
         const setParams = (p: string[]) => params.splice(0, params.length, ...p);
         const scriptingBox = <ScriptBox initialText={originalText} setParams={setParams} onCancel={overlayDisposer} onSave={(text, onError) => {
-            if (prewrapper) {
-                text = prewrapper + text + (postwrapper ? postwrapper : "");
-            }
             const script = CompileScript(text, {
-                params: { this: Doc.name },
+                params: { this: Doc.name, ...contextParams },
                 typecheck: false,
                 editable: true,
                 transformer: DocumentIconContainer.getTransformer()
-- 
cgit v1.2.3-70-g09d2

