refactoring
This commit is contained in:
parent
80c747af69
commit
e9a9abea4c
@ -47,6 +47,7 @@ import {
|
|||||||
CalculatedFieldScriptTestDialogComponent
|
CalculatedFieldScriptTestDialogComponent
|
||||||
} from './components/public-api';
|
} from './components/public-api';
|
||||||
import { ImportExportService } from '@shared/import-export/import-export.service';
|
import { ImportExportService } from '@shared/import-export/import-export.service';
|
||||||
|
import { isObject } from '@core/utils';
|
||||||
|
|
||||||
export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedField, PageLink> {
|
export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedField, PageLink> {
|
||||||
|
|
||||||
@ -206,7 +207,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
|
|||||||
getTestScriptDialogFn: this.getTestScriptDialog.bind(this),
|
getTestScriptDialogFn: this.getTestScriptDialog.bind(this),
|
||||||
isDirty
|
isDirty
|
||||||
},
|
},
|
||||||
...(isDirty ? { enterAnimationDuration: 0 } : {})
|
enterAnimationDuration: isDirty ? 0 : null,
|
||||||
})
|
})
|
||||||
.afterClosed();
|
.afterClosed();
|
||||||
}
|
}
|
||||||
@ -261,11 +262,8 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getTestScriptDialog(calculatedField: CalculatedField, argumentsObj?: Record<string, unknown>, openCalculatedFieldEdit = true): Observable<string> {
|
private getTestScriptDialog(calculatedField: CalculatedField, argumentsObj?: Record<string, unknown>, openCalculatedFieldEdit = true): Observable<string> {
|
||||||
const emptyArguments = Object.keys(calculatedField.configuration.arguments).reduce((acc, key) => { acc[key] = ''; return acc; }, {});
|
const resultArguments = Object.keys(calculatedField.configuration.arguments).reduce((acc, key) => {
|
||||||
const filledArguments = Object.keys(argumentsObj ?? {}).reduce((acc, key) => {
|
acc[key] = isObject(argumentsObj) && argumentsObj.hasOwnProperty(key) ? argumentsObj[key] : '';
|
||||||
if (emptyArguments.hasOwnProperty(key)) {
|
|
||||||
acc[key] = argumentsObj[key];
|
|
||||||
}
|
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
return this.dialog.open<CalculatedFieldScriptTestDialogComponent, CalculatedFieldTestScriptDialogData, string>(CalculatedFieldScriptTestDialogComponent,
|
return this.dialog.open<CalculatedFieldScriptTestDialogComponent, CalculatedFieldTestScriptDialogData, string>(CalculatedFieldScriptTestDialogComponent,
|
||||||
@ -273,7 +271,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
|
|||||||
disableClose: true,
|
disableClose: true,
|
||||||
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-fullscreen-dialog-gt-xs'],
|
panelClass: ['tb-dialog', 'tb-fullscreen-dialog', 'tb-fullscreen-dialog-gt-xs'],
|
||||||
data: {
|
data: {
|
||||||
arguments: { ...emptyArguments, ...filledArguments },
|
arguments: resultArguments,
|
||||||
expression: calculatedField.configuration.expression,
|
expression: calculatedField.configuration.expression,
|
||||||
openCalculatedFieldEdit
|
openCalculatedFieldEdit
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user