UI: Added global scope variables in javascript functions
This commit is contained in:
parent
894a1df1f6
commit
d08e6dba5d
@ -68,6 +68,10 @@ export class WidgetService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getWidgetScopeVariables(): string[] {
|
||||||
|
return ['tinycolor', 'cssjs', 'moment', '$', 'jQuery'];
|
||||||
|
}
|
||||||
|
|
||||||
public getAllWidgetsBundles(config?: RequestConfig): Observable<Array<WidgetsBundle>> {
|
public getAllWidgetsBundles(config?: RequestConfig): Observable<Array<WidgetsBundle>> {
|
||||||
return this.loadWidgetsBundleCache(config).pipe(
|
return this.loadWidgetsBundleCache(config).pipe(
|
||||||
map(() => this.allWidgetsBundles)
|
map(() => this.allWidgetsBundles)
|
||||||
@ -311,5 +315,4 @@ export class WidgetService {
|
|||||||
this.loadWidgetsBundleCacheSubject = undefined;
|
this.loadWidgetsBundleCacheSubject = undefined;
|
||||||
this.widgetTypeInfosCache.clear();
|
this.widgetTypeInfosCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,6 +44,7 @@
|
|||||||
(ngModelChange)="onActionUpdated()"
|
(ngModelChange)="onActionUpdated()"
|
||||||
[fillHeight]="true"
|
[fillHeight]="true"
|
||||||
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'htmlTemplate', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'htmlTemplate', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[validationArgs]="[]"
|
[validationArgs]="[]"
|
||||||
[editorCompleter]="customPrettyActionEditorCompleter">
|
[editorCompleter]="customPrettyActionEditorCompleter">
|
||||||
</tb-js-func>
|
</tb-js-func>
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import { AppState } from '@core/core.state';
|
|||||||
import { combineLatest } from 'rxjs';
|
import { combineLatest } from 'rxjs';
|
||||||
import { CustomActionDescriptor } from '@shared/models/widget.models';
|
import { CustomActionDescriptor } from '@shared/models/widget.models';
|
||||||
import { CustomPrettyActionEditorCompleter } from '@home/components/widget/action/custom-action.models';
|
import { CustomPrettyActionEditorCompleter } from '@home/components/widget/action/custom-action.models';
|
||||||
|
import { WidgetService } from "@core/http/widget.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-custom-action-pretty-editor',
|
selector: 'tb-custom-action-pretty-editor',
|
||||||
@ -58,6 +59,8 @@ export class CustomActionPrettyEditorComponent extends PageComponent implements
|
|||||||
|
|
||||||
fullscreen = false;
|
fullscreen = false;
|
||||||
|
|
||||||
|
functionScopeVariables: string[];
|
||||||
|
|
||||||
@ViewChildren('leftPanel')
|
@ViewChildren('leftPanel')
|
||||||
leftPanelElmRef: QueryList<ElementRef<HTMLElement>>;
|
leftPanelElmRef: QueryList<ElementRef<HTMLElement>>;
|
||||||
|
|
||||||
@ -68,8 +71,10 @@ export class CustomActionPrettyEditorComponent extends PageComponent implements
|
|||||||
|
|
||||||
private propagateChange = (_: any) => {};
|
private propagateChange = (_: any) => {};
|
||||||
|
|
||||||
constructor(protected store: Store<AppState>) {
|
constructor(protected store: Store<AppState>,
|
||||||
|
private widgetService: WidgetService) {
|
||||||
super(store);
|
super(store);
|
||||||
|
this.functionScopeVariables = this.widgetService.getWidgetScopeVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@ -94,6 +94,7 @@
|
|||||||
[(ngModel)]="action.customFunction"
|
[(ngModel)]="action.customFunction"
|
||||||
(ngModelChange)="notifyActionUpdated()"
|
(ngModelChange)="notifyActionUpdated()"
|
||||||
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'htmlTemplate', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'htmlTemplate', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[validationArgs]="[]"
|
[validationArgs]="[]"
|
||||||
[editorCompleter]="customPrettyActionEditorCompleter">
|
[editorCompleter]="customPrettyActionEditorCompleter">
|
||||||
</tb-js-func>
|
</tb-js-func>
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import { forkJoin, from } from 'rxjs';
|
|||||||
import { map, tap } from 'rxjs/operators';
|
import { map, tap } from 'rxjs/operators';
|
||||||
import { getAce } from '@shared/models/ace/ace.models';
|
import { getAce } from '@shared/models/ace/ace.models';
|
||||||
import { beautifyCss, beautifyHtml } from '@shared/models/beautify.models';
|
import { beautifyCss, beautifyHtml } from '@shared/models/beautify.models';
|
||||||
|
import { WidgetService } from "@core/http/widget.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-custom-action-pretty-resources-tabs',
|
selector: 'tb-custom-action-pretty-resources-tabs',
|
||||||
@ -75,12 +76,16 @@ export class CustomActionPrettyResourcesTabsComponent extends PageComponent impl
|
|||||||
cssEditor: Ace.Editor;
|
cssEditor: Ace.Editor;
|
||||||
setValuesPending = false;
|
setValuesPending = false;
|
||||||
|
|
||||||
|
functionScopeVariables: string[];
|
||||||
|
|
||||||
customPrettyActionEditorCompleter = CustomPrettyActionEditorCompleter;
|
customPrettyActionEditorCompleter = CustomPrettyActionEditorCompleter;
|
||||||
|
|
||||||
constructor(protected store: Store<AppState>,
|
constructor(protected store: Store<AppState>,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
|
private widgetService: WidgetService,
|
||||||
private raf: RafService) {
|
private raf: RafService) {
|
||||||
super(store);
|
super(store);
|
||||||
|
this.functionScopeVariables = this.widgetService.getWidgetScopeVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
formControlName="getLocationFunction"
|
formControlName="getLocationFunction"
|
||||||
functionName="getLocation"
|
functionName="getLocation"
|
||||||
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[editorCompleter]="customActionEditorCompleter"
|
[editorCompleter]="customActionEditorCompleter"
|
||||||
></tb-js-func>
|
></tb-js-func>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@ -43,6 +44,7 @@
|
|||||||
formControlName="getPhoneNumberFunction"
|
formControlName="getPhoneNumberFunction"
|
||||||
functionName="getPhoneNumber"
|
functionName="getPhoneNumber"
|
||||||
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[editorCompleter]="customActionEditorCompleter"
|
[editorCompleter]="customActionEditorCompleter"
|
||||||
></tb-js-func>
|
></tb-js-func>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@ -54,6 +56,7 @@
|
|||||||
formControlName="processImageFunction"
|
formControlName="processImageFunction"
|
||||||
functionName="processImage"
|
functionName="processImage"
|
||||||
[functionArgs]="['imageUrl', '$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['imageUrl', '$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[editorCompleter]="customActionEditorCompleter"
|
[editorCompleter]="customActionEditorCompleter"
|
||||||
></tb-js-func>
|
></tb-js-func>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@ -62,6 +65,7 @@
|
|||||||
formControlName="processQrCodeFunction"
|
formControlName="processQrCodeFunction"
|
||||||
functionName="processQrCode"
|
functionName="processQrCode"
|
||||||
[functionArgs]="['code', 'format', '$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['code', 'format', '$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[editorCompleter]="customActionEditorCompleter"
|
[editorCompleter]="customActionEditorCompleter"
|
||||||
></tb-js-func>
|
></tb-js-func>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@ -70,6 +74,7 @@
|
|||||||
formControlName="processLocationFunction"
|
formControlName="processLocationFunction"
|
||||||
functionName="processLocation"
|
functionName="processLocation"
|
||||||
[functionArgs]="['latitude', 'longitude', '$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['latitude', 'longitude', '$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[editorCompleter]="customActionEditorCompleter"
|
[editorCompleter]="customActionEditorCompleter"
|
||||||
></tb-js-func>
|
></tb-js-func>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@ -81,6 +86,7 @@
|
|||||||
formControlName="processLaunchResultFunction"
|
formControlName="processLaunchResultFunction"
|
||||||
functionName="processLaunchResult"
|
functionName="processLaunchResult"
|
||||||
[functionArgs]="['launched', '$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['launched', '$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[editorCompleter]="customActionEditorCompleter"
|
[editorCompleter]="customActionEditorCompleter"
|
||||||
></tb-js-func>
|
></tb-js-func>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@ -89,12 +95,14 @@
|
|||||||
formControlName="handleEmptyResultFunction"
|
formControlName="handleEmptyResultFunction"
|
||||||
functionName="handleEmptyResult"
|
functionName="handleEmptyResult"
|
||||||
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[editorCompleter]="customActionEditorCompleter"
|
[editorCompleter]="customActionEditorCompleter"
|
||||||
></tb-js-func>
|
></tb-js-func>
|
||||||
<tb-js-func *ngIf="mobileActionFormGroup.get('type').value"
|
<tb-js-func *ngIf="mobileActionFormGroup.get('type').value"
|
||||||
formControlName="handleErrorFunction"
|
formControlName="handleErrorFunction"
|
||||||
functionName="handleError"
|
functionName="handleError"
|
||||||
[functionArgs]="['error', '$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['error', '$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[editorCompleter]="customActionEditorCompleter"
|
[editorCompleter]="customActionEditorCompleter"
|
||||||
></tb-js-func>
|
></tb-js-func>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -14,26 +14,29 @@
|
|||||||
/// limitations under the License.
|
/// limitations under the License.
|
||||||
///
|
///
|
||||||
|
|
||||||
import { Component, forwardRef, Input, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
|
import { Component, forwardRef, Input, OnInit, QueryList, ViewChildren } from '@angular/core';
|
||||||
import { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
|
import { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppState } from '@app/core/core.state';
|
import { AppState } from '@app/core/core.state';
|
||||||
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
||||||
import { deepClone } from '@core/utils';
|
|
||||||
import {
|
import {
|
||||||
WidgetMobileActionDescriptor,
|
WidgetMobileActionDescriptor,
|
||||||
WidgetMobileActionType, widgetMobileActionTypeTranslationMap
|
WidgetMobileActionType,
|
||||||
|
widgetMobileActionTypeTranslationMap
|
||||||
} from '@shared/models/widget.models';
|
} from '@shared/models/widget.models';
|
||||||
import { CustomActionEditorCompleter } from '@home/components/widget/action/custom-action.models';
|
import { CustomActionEditorCompleter } from '@home/components/widget/action/custom-action.models';
|
||||||
import { JsFuncComponent } from '@shared/components/js-func.component';
|
import { JsFuncComponent } from '@shared/components/js-func.component';
|
||||||
import {
|
import {
|
||||||
getDefaultGetLocationFunction, getDefaultGetPhoneNumberFunction,
|
getDefaultGetLocationFunction,
|
||||||
|
getDefaultGetPhoneNumberFunction,
|
||||||
getDefaultHandleEmptyResultFunction,
|
getDefaultHandleEmptyResultFunction,
|
||||||
getDefaultHandleErrorFunction,
|
getDefaultHandleErrorFunction,
|
||||||
getDefaultProcessImageFunction,
|
getDefaultProcessImageFunction,
|
||||||
getDefaultProcessLaunchResultFunction, getDefaultProcessLocationFunction,
|
getDefaultProcessLaunchResultFunction,
|
||||||
|
getDefaultProcessLocationFunction,
|
||||||
getDefaultProcessQrCodeFunction
|
getDefaultProcessQrCodeFunction
|
||||||
} from '@home/components/widget/action/mobile-action-editor.models';
|
} from '@home/components/widget/action/mobile-action-editor.models';
|
||||||
|
import { WidgetService } from "@core/http/widget.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-mobile-action-editor',
|
selector: 'tb-mobile-action-editor',
|
||||||
@ -58,6 +61,8 @@ export class MobileActionEditorComponent implements ControlValueAccessor, OnInit
|
|||||||
mobileActionFormGroup: FormGroup;
|
mobileActionFormGroup: FormGroup;
|
||||||
mobileActionTypeFormGroup: FormGroup;
|
mobileActionTypeFormGroup: FormGroup;
|
||||||
|
|
||||||
|
functionScopeVariables: string[];
|
||||||
|
|
||||||
private requiredValue: boolean;
|
private requiredValue: boolean;
|
||||||
get required(): boolean {
|
get required(): boolean {
|
||||||
return this.requiredValue;
|
return this.requiredValue;
|
||||||
@ -73,7 +78,9 @@ export class MobileActionEditorComponent implements ControlValueAccessor, OnInit
|
|||||||
private propagateChange = (v: any) => { };
|
private propagateChange = (v: any) => { };
|
||||||
|
|
||||||
constructor(private store: Store<AppState>,
|
constructor(private store: Store<AppState>,
|
||||||
private fb: FormBuilder) {
|
private fb: FormBuilder,
|
||||||
|
private widgetService: WidgetService) {
|
||||||
|
this.functionScopeVariables = this.widgetService.getWidgetScopeVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
registerOnChange(fn: any): void {
|
registerOnChange(fn: any): void {
|
||||||
|
|||||||
@ -171,6 +171,7 @@
|
|||||||
<tb-js-func
|
<tb-js-func
|
||||||
formControlName="customFunction"
|
formControlName="customFunction"
|
||||||
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
[functionArgs]="['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', 'entityLabel']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[validationArgs]="[]"
|
[validationArgs]="[]"
|
||||||
[editorCompleter]="customActionEditorCompleter"
|
[editorCompleter]="customActionEditorCompleter"
|
||||||
></tb-js-func>
|
></tb-js-func>
|
||||||
|
|||||||
@ -47,6 +47,7 @@ import { CustomActionEditorCompleter } from '@home/components/widget/action/cust
|
|||||||
import { isDefinedAndNotNull } from '@core/utils';
|
import { isDefinedAndNotNull } from '@core/utils';
|
||||||
import { MobileActionEditorComponent } from '@home/components/widget/action/mobile-action-editor.component';
|
import { MobileActionEditorComponent } from '@home/components/widget/action/mobile-action-editor.component';
|
||||||
import { widgetType } from '@shared/models/widget.models';
|
import { widgetType } from '@shared/models/widget.models';
|
||||||
|
import { WidgetService } from "@core/http/widget.service";
|
||||||
|
|
||||||
export interface WidgetActionDialogData {
|
export interface WidgetActionDialogData {
|
||||||
isAdd: boolean;
|
isAdd: boolean;
|
||||||
@ -88,11 +89,14 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
|
|||||||
submitted = false;
|
submitted = false;
|
||||||
widgetType = widgetType;
|
widgetType = widgetType;
|
||||||
|
|
||||||
|
functionScopeVariables: string[];
|
||||||
|
|
||||||
constructor(protected store: Store<AppState>,
|
constructor(protected store: Store<AppState>,
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
private utils: UtilsService,
|
private utils: UtilsService,
|
||||||
private dashboardService: DashboardService,
|
private dashboardService: DashboardService,
|
||||||
private dashboardUtils: DashboardUtilsService,
|
private dashboardUtils: DashboardUtilsService,
|
||||||
|
private widgetService: WidgetService,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: WidgetActionDialogData,
|
@Inject(MAT_DIALOG_DATA) public data: WidgetActionDialogData,
|
||||||
@SkipSelf() private errorStateMatcher: ErrorStateMatcher,
|
@SkipSelf() private errorStateMatcher: ErrorStateMatcher,
|
||||||
public dialogRef: MatDialogRef<WidgetActionDialogComponent, WidgetActionDescriptorInfo>,
|
public dialogRef: MatDialogRef<WidgetActionDialogComponent, WidgetActionDescriptorInfo>,
|
||||||
@ -109,6 +113,7 @@ export class WidgetActionDialogComponent extends DialogComponent<WidgetActionDia
|
|||||||
} else {
|
} else {
|
||||||
this.action = this.data.action;
|
this.action = this.data.action;
|
||||||
}
|
}
|
||||||
|
this.functionScopeVariables = this.widgetService.getWidgetScopeVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@ -67,6 +67,7 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<tb-js-func #funcBodyEdit
|
<tb-js-func #funcBodyEdit
|
||||||
[functionArgs]="['time', 'prevValue']"
|
[functionArgs]="['time', 'prevValue']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[validationArgs]="[[1, 1],[1, '1']]"
|
[validationArgs]="[[1, 1],[1, '1']]"
|
||||||
resultType="any"
|
resultType="any"
|
||||||
formControlName="funcBody">
|
formControlName="funcBody">
|
||||||
@ -78,6 +79,7 @@
|
|||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
<tb-js-func *ngIf="dataKeyFormGroup.get('usePostProcessing').value" #postFuncBodyEdit
|
<tb-js-func *ngIf="dataKeyFormGroup.get('usePostProcessing').value" #postFuncBodyEdit
|
||||||
[functionArgs]="['time', 'value', 'prevValue', 'timePrev', 'prevOrigValue']"
|
[functionArgs]="['time', 'value', 'prevValue', 'timePrev', 'prevOrigValue']"
|
||||||
|
[globalVariables]="functionScopeVariables"
|
||||||
[validationArgs]="[[1, 1, 1, 1, 1],[1, '1', '1', 1, '1']]"
|
[validationArgs]="[[1, 1, 1, 1, 1],[1, '1', '1', 1, '1']]"
|
||||||
resultType="any"
|
resultType="any"
|
||||||
formControlName="postFuncBody">
|
formControlName="postFuncBody">
|
||||||
|
|||||||
@ -40,6 +40,7 @@ import { map, mergeMap, publishReplay, refCount, tap } from 'rxjs/operators';
|
|||||||
import { alarmFields } from '@shared/models/alarm.models';
|
import { alarmFields } from '@shared/models/alarm.models';
|
||||||
import { JsFuncComponent } from '@shared/components/js-func.component';
|
import { JsFuncComponent } from '@shared/components/js-func.component';
|
||||||
import { JsonFormComponentData } from '@shared/components/json-form/json-form-component.models';
|
import { JsonFormComponentData } from '@shared/components/json-form/json-form-component.models';
|
||||||
|
import { WidgetService } from "@core/http/widget.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-data-key-config',
|
selector: 'tb-data-key-config',
|
||||||
@ -99,13 +100,17 @@ export class DataKeyConfigComponent extends PageComponent implements OnInit, Con
|
|||||||
|
|
||||||
keySearchText = '';
|
keySearchText = '';
|
||||||
|
|
||||||
|
functionScopeVariables: string[];
|
||||||
|
|
||||||
constructor(protected store: Store<AppState>,
|
constructor(protected store: Store<AppState>,
|
||||||
private utils: UtilsService,
|
private utils: UtilsService,
|
||||||
private entityService: EntityService,
|
private entityService: EntityService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
|
private widgetService: WidgetService,
|
||||||
private fb: FormBuilder) {
|
private fb: FormBuilder) {
|
||||||
super(store);
|
super(store);
|
||||||
|
this.functionScopeVariables = this.widgetService.getWidgetScopeVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@ -83,6 +83,8 @@ export class JsFuncComponent implements OnInit, OnDestroy, ControlValueAccessor,
|
|||||||
|
|
||||||
@Input() editorCompleter: TbEditorCompleter;
|
@Input() editorCompleter: TbEditorCompleter;
|
||||||
|
|
||||||
|
@Input() globalVariables: Array<string>;
|
||||||
|
|
||||||
private noValidateValue: boolean;
|
private noValidateValue: boolean;
|
||||||
get noValidate(): boolean {
|
get noValidate(): boolean {
|
||||||
return this.noValidateValue;
|
return this.noValidateValue;
|
||||||
@ -190,6 +192,11 @@ export class JsFuncComponent implements OnInit, OnDestroy, ControlValueAccessor,
|
|||||||
jsWorkerOptions.globals[arg] = false;
|
jsWorkerOptions.globals[arg] = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (this.globalVariables) {
|
||||||
|
this.globalVariables.forEach(arg => {
|
||||||
|
jsWorkerOptions.globals[arg] = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.jsEditor.session.$worker.send('changeOptions', [jsWorkerOptions]);
|
this.jsEditor.session.$worker.send('changeOptions', [jsWorkerOptions]);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user