From eaee5ce4ad484133d863c1ea3e3aee00101a720f Mon Sep 17 00:00:00 2001 From: anika-ahluwalia Date: Tue, 26 May 2020 12:06:18 -0500 Subject: comments and minor color change --- src/client/views/nodes/ScriptingBox.scss | 7 ++++--- src/client/views/nodes/ScriptingBox.tsx | 34 +++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/ScriptingBox.scss b/src/client/views/nodes/ScriptingBox.scss index b12c07ade..d369045f4 100644 --- a/src/client/views/nodes/ScriptingBox.scss +++ b/src/client/views/nodes/ScriptingBox.scss @@ -44,7 +44,7 @@ overflow-y: scroll; .scriptingBox-pborder { - background-color: white; + background-color: rgb(241, 239, 235); } .scriptingBox-viewBase { @@ -101,7 +101,7 @@ } .scripting-params { - background: "beige"; + background: rgb(241, 239, 235); } } @@ -113,8 +113,9 @@ width: 50%; resize: auto; } + .scriptingBox-button-third { - width:33%; + width: 33%; } } } \ No newline at end of file diff --git a/src/client/views/nodes/ScriptingBox.tsx b/src/client/views/nodes/ScriptingBox.tsx index db8a8b559..181db4b51 100644 --- a/src/client/views/nodes/ScriptingBox.tsx +++ b/src/client/views/nodes/ScriptingBox.tsx @@ -34,6 +34,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent p.split(":")[0].trim()); } @computed get paramsTypes() { return this.compileParams.map(p => p.split(":")[1].trim()); } @computed get rawScript() { return StrCast(this.dataDoc[this.props.fieldKey + "-rawScript"], ""); } @@ -55,6 +56,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent { this.rootDoc.layoutKey = "layout"; @@ -63,11 +65,13 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent { this._errorMessage = error?.map((entry: any) => entry.messageText).join(" ") || ""; } + // checks if the script compiles using CompileScript method and inputting params @action onCompile = () => { const params: ScriptParam = {}; @@ -84,14 +88,17 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent { this.onCompile(); const bindings: { [name: string]: any } = {}; this.paramsNames.forEach(key => bindings[key] = this.dataDoc[key]); + // binds vars so user doesnt have to refer to everything as self. ScriptCast(this.dataDoc.data, null)?.script.run({ self: this.rootDoc, this: this.layoutDoc, ...bindings }, this.onError); } + // checks if the script compiles and switches to applied UI @action onApply = () => { this.onCompile(); @@ -103,17 +110,20 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent { this._overlayDisposer?.(); this._overlayDisposer = OverlayView.Instance.addElement(, { x: 0, y: 0 }); } + // sets field of the corresponding field key (param name) to be dropped document @action onDrop = (e: Event, de: DragManager.DropEvent, fieldKey: string) => { this.dataDoc[fieldKey] = de.complete.docDragData?.droppedDocuments[0]; e.stopPropagation(); } + // deletes a param from all areas in which it is stored @action onDelete = (num: number) => { this.dataDoc[this.paramsNames[num]] = undefined; @@ -121,18 +131,21 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent { //@ts-ignore this.dataDoc[name] = e.target.selectedOptions[0].value; } + // creates a copy of the script document onCopy = () => { const copy = Doc.MakeCopy(this.rootDoc, true); copy.x = NumCast(this.dataDoc.x) + NumCast(this.dataDoc._width); this.props.addDocument?.(copy); } + // adds option to create a copy to the context menu specificContextMenu = (e: React.MouseEvent): void => { const existingOptions = ContextMenu.Instance.findByDescription("Options..."); const options = existingOptions && "subitems" in existingOptions ? existingOptions.subitems : []; @@ -144,12 +157,13 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent {this._errorMessage} ; } + // rendering when a doc's value can be set in applied UI renderDoc(parameter: string) { return
this._overlayDisposer?.()} ref={ele => ele && this.createDashEventsTarget(ele, (e, de) => this.onDrop(e, de, parameter))} > this.dataDoc[parameter]?.title ?? ""} + contents={this.dataDoc[parameter]?.title ?? "undefined"} + GetValue={() => this.dataDoc[parameter]?.title ?? "undefined"} SetValue={action((value: string) => { const script = CompileScript(value, { addReturn: true, @@ -169,6 +183,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent; } + // rendering when a string's value can be set in applied UI renderString(parameter: string) { return
; } + // rendering when a number's value can be set in applied UI renderNumber(parameter: string) { return
; } + // rendering when an enum's value can be set in applied UI (drop down box) renderEnum(parameter: string, types: string[]) { return
@@ -224,6 +241,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent; } + // rendering when a boolean's value can be set in applied UI (drop down box) renderBoolean(parameter: string) { return
@@ -240,6 +258,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent; } + // setting a parameter (checking type and name before it is added) compileParam(value: string, whichParam?: number) { if (value.includes(":")) { const ptype = value.split(":")[1].trim(); @@ -264,7 +283,10 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent
; + // main scripting input box const scriptingInputText =