From c232bbfd28937c139ae18727310c91d9c6c2dbec Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Mon, 8 Jun 2020 13:07:11 -0500 Subject: added function UI --- src/client/views/nodes/ScriptingBox.scss | 2 + src/client/views/nodes/ScriptingBox.tsx | 96 +++++++++++++++++++++++++++++--- 2 files changed, 91 insertions(+), 7 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/nodes/ScriptingBox.scss b/src/client/views/nodes/ScriptingBox.scss index f28a2fcef..1e4dc4868 100644 --- a/src/client/views/nodes/ScriptingBox.scss +++ b/src/client/views/nodes/ScriptingBox.scss @@ -35,6 +35,8 @@ flex-direction: row; justify-content: center; + + .scriptingBox-textArea { flex: 70; height: 100%; diff --git a/src/client/views/nodes/ScriptingBox.tsx b/src/client/views/nodes/ScriptingBox.tsx index 6f94ae8f9..2e7b544d2 100644 --- a/src/client/views/nodes/ScriptingBox.tsx +++ b/src/client/views/nodes/ScriptingBox.tsx @@ -39,6 +39,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent p.split(":")[0].trim()); } @computed({ keepAlive: true }) get paramsTypes() { return this.compileParams.map(p => p.split(":")[1].trim()); } @@ -213,20 +217,46 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent { + this._errorMessage = ""; this._applied = false; + this._function = false; } @action onSave = () => { if (this.onCompile()) { - this.dataDoc.funcName = "testingTitle"; - this.dataDoc.descripition = "description test"; - ScriptManager.Instance.addScript(this.dataDoc); + this._function = true; } else { this._errorMessage = "Can not save script, does not compile"; } } + @action + onCreate = () => { + + if (this._functionName.length === 0) { + this._errorMessage = "Must enter a function name"; + return false; + } + + if (this._functionName.indexOf(" ") > 0) { + this._errorMessage = "Name can not include spaces"; + return false; + } + + this.dataDoc.funcName = this._functionName; + this.dataDoc.descripition = this._functionDescription; + + ScriptManager.Instance.deleteScript(this.dataDoc); + + this.dataDoc.funcName = "testingTitle"; + this.dataDoc.descripition = "description test"; + + ScriptManager.Instance.addScript(this.dataDoc); + + console.log("created"); + } + // overlays document numbers (ex. d32) over all documents when clicked on onFocus = () => { this._overlayDisposer?.(); @@ -270,6 +300,40 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent this._functionDescription = e.target.value} + placeholder="enter description here" + value={this._functionDescription} + style={{ height: "40%", width: "100%" }} + />; + + const nameInput = +