diff options
author | anika-ahluwalia <anika.ahluwalia@gmail.com> | 2020-06-10 11:52:46 -0500 |
---|---|---|
committer | anika-ahluwalia <anika.ahluwalia@gmail.com> | 2020-06-10 11:52:46 -0500 |
commit | 367705cf6826766a9102315d75cd690d8e6b8929 (patch) | |
tree | 982d2b364828c7a5ae57c1c57fb7707920440ddd /src/client/views/nodes/ScriptingBox.tsx | |
parent | d6e17e1fd23ac867e13d601a2dae61acbf0a7195 (diff) |
fixed add global method in ScriptManager
Diffstat (limited to 'src/client/views/nodes/ScriptingBox.tsx')
-rw-r--r-- | src/client/views/nodes/ScriptingBox.tsx | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/src/client/views/nodes/ScriptingBox.tsx b/src/client/views/nodes/ScriptingBox.tsx index c2581240b..61f58cb0f 100644 --- a/src/client/views/nodes/ScriptingBox.tsx +++ b/src/client/views/nodes/ScriptingBox.tsx @@ -187,7 +187,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc editable: true, transformer: DocumentIconContainer.getTransformer(), params, - typecheck: true + typecheck: false }); this.dataDoc.documentText = this.rawScript; this.dataDoc.data = result.compiled ? new ScriptField(result) : undefined; @@ -253,38 +253,8 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc this.dataDoc.funcName = this.functionName; this.dataDoc.descripition = this.functionDescription; - // ScriptingBox.DeleteScript?.(this.dataDoc); - // ScriptingBox.AddScript?.(this.dataDoc); - - //const p = this.compileParams.reduce((o: ScriptParam, p: string) => { o[p] = "any"; return o; }, {} as ScriptParam); - //const f = new Function(...Array.from(Object.keys(p)), this.rawScript); - - const paramNames = this.compileParams.reduce((o: string, p: string) => { - if (this.compileParams.indexOf(p) === this.compileParams.length - 1) { - o = o + p.split(":")[0].trim(); - } else { - o = o + p.split(":")[0].trim() + ","; - } - return o; - }, "" as string); - const f = new Function(paramNames, this.rawScript); - - let parameters = "("; - this.compileParams.forEach((element: string, i: number) => { - if (i === this.compileParams.length - 1) { - parameters = parameters + element + ")"; - } else { - parameters = parameters + element + ", "; - } - }); - - console.log(this.functionName); - - if (parameters === "(") { - Scripting.addGlobal(f, this.dataDoc.description, "", this.functionName); - } else { - Scripting.addGlobal(f, this.dataDoc.description, parameters, this.functionName); - } + ScriptingBox.DeleteScript?.(this.dataDoc); + ScriptingBox.AddScript?.(this.dataDoc); console.log("created"); } |