Browse Source

refactoring

pull/12800/head
mpetrov 2 years ago
parent
commit
99beae2115
  1. 19
      ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts

19
ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts

@ -39,6 +39,7 @@ import { map, startWith, switchMap } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ScriptLanguage } from '@shared/models/rule-node.models'; import { ScriptLanguage } from '@shared/models/rule-node.models';
import { CalculatedFieldsService } from '@core/http/calculated-fields.service'; import { CalculatedFieldsService } from '@core/http/calculated-fields.service';
import { Observable } from 'rxjs';
@Component({ @Component({
selector: 'tb-calculated-field-dialog', selector: 'tb-calculated-field-dialog',
@ -137,9 +138,10 @@ export class CalculatedFieldDialogComponent extends DialogComponent<CalculatedFi
onTestScript(): void { onTestScript(): void {
const calculatedFieldId = this.data.value?.id?.id; const calculatedFieldId = this.data.value?.id?.id;
let testScriptDialogResult$: Observable<string>;
(calculatedFieldId if (calculatedFieldId) {
? this.calculatedFieldsService.getLatestCalculatedFieldDebugEvent(calculatedFieldId) testScriptDialogResult$ = this.calculatedFieldsService.getLatestCalculatedFieldDebugEvent(calculatedFieldId)
.pipe( .pipe(
switchMap(event => { switchMap(event => {
const args = event?.arguments ? JSON.parse(event.arguments) : null; const args = event?.arguments ? JSON.parse(event.arguments) : null;
@ -147,11 +149,14 @@ export class CalculatedFieldDialogComponent extends DialogComponent<CalculatedFi
}), }),
takeUntilDestroyed(this.destroyRef) takeUntilDestroyed(this.destroyRef)
) )
: this.data.getTestScriptDialogFn(this.fromGroupValue, null, false)) } else {
.subscribe(expression => { testScriptDialogResult$ = this.data.getTestScriptDialogFn(this.fromGroupValue, null, false);
this.configFormGroup.get('expressionSCRIPT').setValue(expression); }
this.configFormGroup.get('expressionSCRIPT').markAsDirty();
}); testScriptDialogResult$.subscribe(expression => {
this.configFormGroup.get('expressionSCRIPT').setValue(expression);
this.configFormGroup.get('expressionSCRIPT').markAsDirty();
});
} }
private applyDialogData(): void { private applyDialogData(): void {

Loading…
Cancel
Save