diff options
Diffstat (limited to 'src/client/views/nodes/ScriptingBox.tsx')
-rw-r--r-- | src/client/views/nodes/ScriptingBox.tsx | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/client/views/nodes/ScriptingBox.tsx b/src/client/views/nodes/ScriptingBox.tsx index 38a43e8d4..7887bab5d 100644 --- a/src/client/views/nodes/ScriptingBox.tsx +++ b/src/client/views/nodes/ScriptingBox.tsx @@ -126,7 +126,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() } @action - resetSuggestionPos(caret: { top: number; left: number; height: number }) { + resetSuggestionPos = (caret: { top: number; left: number; height: number }) => { if (!this._suggestionRef.current || !this._scriptTextRef.current) return; const suggestionWidth = this._suggestionRef.current.offsetWidth; const scriptWidth = this._scriptTextRef.current.offsetWidth; @@ -140,7 +140,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() this._suggestionBoxX = left; this._suggestionBoxY = top; - } + }; componentWillUnmount() { this._overlayDisposer?.(); @@ -305,7 +305,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() !existingOptions && ContextMenu.Instance.addItem({ description: 'Options...', subitems: options, icon: 'hand-point-right' }); }; - renderFunctionInputs() { + renderFunctionInputs = () => { const descriptionInput = ( <textarea className="scriptingBox-textarea-inputs" @@ -346,14 +346,14 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {this.renderErrorMessage()} </div> ); - } + }; - renderErrorMessage() { + renderErrorMessage = () => { return !this._errorMessage ? null : <div className="scriptingBox-errorMessage"> {this._errorMessage} </div>; - } + }; // rendering when a doc's value can be set in applied UI - renderDoc(parameter: string) { + renderDoc = (parameter: string) => { return ( <div className="scriptingBox-paramInputs" onFocus={this.onFocus} onBlur={() => this._overlayDisposer?.()} ref={ele => ele && this.createDashEventsTarget(ele, (e, de) => this.onDrop(e, de, parameter))}> <EditableView @@ -381,10 +381,10 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() /> </div> ); - } + }; // rendering when a string's value can be set in applied UI - renderBasicType(parameter: string, isNum: boolean) { + renderBasicType = (parameter: string, isNum: boolean) => { const strVal = isNum ? NumCast(this.dataDoc[parameter]).toString() : StrCast(this.dataDoc[parameter]); return ( <div className="scriptingBox-paramInputs" style={{ overflowY: 'hidden' }}> @@ -408,10 +408,10 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() /> </div> ); - } + }; // rendering when an enum's value can be set in applied UI (drop down box) - renderEnum(parameter: string, types: (string | boolean | number)[]) { + renderEnum = (parameter: string, types: (string | boolean | number)[]) => { return ( <div className="scriptingBox-paramInputs"> <div className="scriptingBox-viewBase"> @@ -432,10 +432,10 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() </div> </div> ); - } + }; // setting a parameter (checking type and name before it is added) - compileParam(value: string, whichParam?: number) { + compileParam = (value: string, whichParam?: number) => { if (value.includes(':')) { const ptype = value.split(':')[1].trim(); const pname = value.split(':')[0].trim(); @@ -457,10 +457,10 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() this._errorMessage = 'must set type of parameter'; } return false; - } + }; @action - handleToken(str: string) { + handleToken = (str: string) => { this._currWord = str; this._suggestions = []; this._scriptKeys.forEach((element: string) => { @@ -469,27 +469,27 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() } }); return this._suggestions; - } + }; @action - handleFunc(pos: number) { + handleFunc = (pos: number) => { const scriptString = this.rawText.slice(0, pos - 2); this._currWord = scriptString.split(' ')[scriptString.split(' ').length - 1]; this._suggestions = [StrCast(this._scriptingParams[this._currWord])]; return this._suggestions; - } + }; - getDescription(value: string) { + getDescription = (value: string) => { const descrip = this._scriptingDescriptions[value]; return descrip?.length > 0 ? descrip : ''; - } + }; - getParams(value: string) { + getParams = (value: string) => { const params = this._scriptingParams[value]; return params?.length > 0 ? params : ''; - } + }; - returnParam(item: string) { + returnParam = (item: string) => { const params = item.split(','); let value = ''; let first = true; @@ -502,15 +502,15 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() } }); return value; - } + }; - getSuggestedParams(pos: number) { + getSuggestedParams = (pos: number) => { const firstScript = this.rawText.slice(0, pos); const indexP = firstScript.lastIndexOf('.'); const indexS = firstScript.lastIndexOf(' '); const func = firstScript.slice((indexP > indexS ? indexP : indexS) + 1, firstScript.length + 1); return this._scriptingParams[func]; - } + }; @action suggestionPos = () => { @@ -524,7 +524,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() }; @action - keyHandler(e: React.KeyboardEvent, pos: number) { + keyHandler = (e: React.KeyboardEvent, pos: number) => { e.stopPropagation(); if (this._lastChar === 'Enter') { this.rawText += ' '; @@ -588,10 +588,10 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() </div> ); } - } + }; @action - handlePosChange(number: number) { + handlePosChange = (number: number) => { this._caretPos = number; if (this._caretPos === 0) { this.rawText = ' ' + this.rawText; @@ -601,7 +601,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() this.rawText = this.rawText.slice(0, this._caretPos - 1) + this.rawText.slice(this._caretPos, this.rawText.length); } } - } + }; @observable rawText: string = ''; @computed({ keepAlive: true }) get renderScriptingBox() { @@ -645,7 +645,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() ); } - renderFuncListElement(value: string | object) { + renderFuncListElement = (value: string | object) => { return typeof value !== 'string' ? null : ( <div> <div style={{ fontSize: '14px' }}>{value}</div> @@ -657,7 +657,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() </div> </div> ); - } + }; // inputs for scripting div (script box, params box, and params column) @computed get renderScriptingInputs() { @@ -704,7 +704,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() } // toolbar (with compile and apply buttons) for scripting UI - renderScriptingTools() { + renderScriptingTools = () => { const buttonStyle = 'scriptingBox-button' + (StrCast(this.Document.layout_fieldKey).startsWith('layout_on') ? '-finish' : ''); return ( <div className="scriptingBox-toolbar"> @@ -745,10 +745,10 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() )} </div> ); - } + }; // inputs UI for params which allows you to set values for each displayed in a list - renderParamsInputs() { + renderParamsInputs = () => { return ( <div className="scriptingBox-inputDiv" onPointerDown={e => this._props.isSelected() && e.stopPropagation()}> {!this.compileParams.length || !this.paramsNames ? null : ( @@ -775,10 +775,10 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {this.renderErrorMessage()} </div> ); - } + }; // toolbar (with edit and run buttons and error message) for params UI - renderTools(toolSet: string, func: () => void) { + renderTools = (toolSet: string, func: () => void) => { const buttonStyle = 'scriptingBox-button' + (StrCast(this.Document.layout_fieldKey).startsWith('layout_on') ? '-finish' : ''); return ( <div className="scriptingBox-toolbar"> @@ -810,7 +810,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent<FieldViewProps>() )} </div> ); - } + }; // renders script UI if _applied = false and params UI if _applied = true render() { |