aboutsummaryrefslogtreecommitdiff
path: root/src/client/views
diff options
context:
space:
mode:
authoranika-ahluwalia <anika.ahluwalia@gmail.com>2020-06-11 13:19:30 -0500
committeranika-ahluwalia <anika.ahluwalia@gmail.com>2020-06-11 13:19:30 -0500
commited6780f7a16e76165bbfc4dbcefe2d77ea40581c (patch)
tree4e95eec7a3140031c4ce46c50e69896c99fc6d1e /src/client/views
parenteaa59f4fb3676f8d222faca88e84b54be2427ef3 (diff)
reworking descriptions and params of functions
Diffstat (limited to 'src/client/views')
-rw-r--r--src/client/views/nodes/ScriptingBox.tsx57
1 files changed, 22 insertions, 35 deletions
diff --git a/src/client/views/nodes/ScriptingBox.tsx b/src/client/views/nodes/ScriptingBox.tsx
index 161ca88e9..60cd02678 100644
--- a/src/client/views/nodes/ScriptingBox.tsx
+++ b/src/client/views/nodes/ScriptingBox.tsx
@@ -40,8 +40,12 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
@observable private _function: boolean = false;
@observable private _hovered: boolean = false;
@observable private _spaced: boolean = false;
+
@observable private _scriptKeys: any = Scripting.getGlobals();
@observable private _scriptGlobals: any = Scripting.getGlobalObj();
+ @observable private _scriptingDescriptions: any = Scripting.getDescriptions();
+ @observable private _scriptingParams: any = Scripting.getParameters();
+
@observable private _currWord: string = "";
@observable private _suggestions: string[] = [];
@@ -73,26 +77,6 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
set compileParams(value) { this.dataDoc[this.props.fieldKey + "-params"] = new List<string>(value); }
- // WORK ON THIS
- // in: global, description, params
- @computed get _descriptions() {
- const descrip: string[] = [];
- this._scriptKeys.forEach((element: any) => {
- const result = this._scriptGlobals[element];
- descrip.push(this.getValue(result, true));
- });
- return descrip;
- }
-
- @computed get _scriptParams() {
- const params: string[] = [];
- this._scriptKeys.forEach((element: any) => {
- const result = this._scriptGlobals[element];
- params.push(this.getValue(result, false));
- });
- return params;
- }
-
getValue(result: any, descrip: boolean) {
let value = "";
if (typeof result === "object") {
@@ -113,7 +97,6 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
return value;
}
-
@action
componentDidMount() {
this.rawScript = ScriptCast(this.dataDoc[this.props.fieldKey])?.script?.originalScript ?? this.rawScript;
@@ -250,18 +233,22 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
return false;
}
+ if (this.functionName.indexOf(".") > 0) {
+ this._errorMessage = "Name can not include '.'";
+ return false;
+ }
+
this.dataDoc.name = this.functionName;
this.dataDoc.description = this.functionDescription;
//this.dataDoc.parameters = this.compileParams;
this.dataDoc.script = this.rawScript;
- //ScriptManager.Instance.deleteScript(this.dataDoc);
ScriptManager.Instance.addScript(this.dataDoc);
- console.log("created");
-
this._scriptKeys = Scripting.getGlobals();
this._scriptGlobals = Scripting.getGlobalObj();
+ this._scriptingDescriptions = Scripting.getDescriptions();
+ this._scriptingParams = Scripting.getParameters();
}
// overlays document numbers (ex. d32) over all documents when clicked on
@@ -487,16 +474,14 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
const scriptString = this.rawScript.slice(0, pos - 2);
this._currWord = scriptString.split(" ")[scriptString.split(" ").length - 1];
this._suggestions = [];
- const index = this._scriptKeys.indexOf(this._currWord);
- const params = StrCast(this._scriptParams[index]);
+ const params = StrCast(this._scriptingParams[this._currWord]);
this._suggestions.push(params);
return (this._suggestions);
}
getDescription(value: string) {
- const index = this._scriptKeys.indexOf(value);
- const descrip = this._descriptions[index];
+ const descrip = this._scriptingDescriptions[value];
let display = "";
if (descrip !== undefined) {
if (descrip.length > 0) {
@@ -507,12 +492,11 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
}
getParams(value: string) {
- const index = this._scriptKeys.indexOf(value);
- const descrip = this._scriptParams[index];
+ const params = this._scriptingParams[value];
let display = "";
- if (descrip !== undefined) {
- if (descrip.length > 0) {
- display = descrip;
+ if (params !== undefined) {
+ if (params.length > 0) {
+ display = params;
}
}
return display;
@@ -547,8 +531,11 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps, Sc
} else {
func = firstScript.slice(indexS + 1, firstScript.length + 1);
}
- const indexF = this._scriptKeys.indexOf(func);
- return this._scriptParams[indexF];
+ if (this._scriptingParams[func]) {
+ return this._scriptingParams[func];
+ } else {
+ return "";
+ }
}
@action