Browse Source

UI: Fixed entities table widgets value formatter for legacy config

pull/13469/head
Vladyslav_Prykhodko 1 year ago
parent
commit
6f31165f60
  1. 6
      ui-ngx/src/app/modules/home/components/widget/lib/entity/entities-table-widget.component.ts
  2. 2
      ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts

6
ui-ngx/src/app/modules/home/components/widget/lib/entity/entities-table-widget.component.ts

@ -167,7 +167,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
private defaultPageSize; private defaultPageSize;
private defaultSortOrder = 'entityName'; private defaultSortOrder = 'entityName';
private contentsInfo: {[key: string]: CellContentInfo} = {}; private contentsInfo: {[key: string]: WithOptional<CellContentInfo, 'valueFormat'>} = {};
private stylesInfo: {[key: string]: Observable<CellStyleInfo>} = {}; private stylesInfo: {[key: string]: Observable<CellStyleInfo>} = {};
private columnWidth: {[key: string]: string} = {}; private columnWidth: {[key: string]: string} = {};
private columnDefaultVisibility: {[key: string]: boolean} = {}; private columnDefaultVisibility: {[key: string]: boolean} = {};
@ -760,7 +760,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
return content$; return content$;
} }
private defaultContent(key: EntityColumn, contentInfo: CellContentInfo, value: any): any { private defaultContent(key: EntityColumn, contentInfo: WithOptional<CellContentInfo, 'valueFormat'>, value: any): any {
if (isDefined(value)) { if (isDefined(value)) {
const entityField = entityFields[key.name]; const entityField = entityFields[key.name];
if (entityField) { if (entityField) {
@ -768,7 +768,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
return this.datePipe.transform(value, 'yyyy-MM-dd HH:mm:ss'); return this.datePipe.transform(value, 'yyyy-MM-dd HH:mm:ss');
} }
} }
return contentInfo.valueFormat.format(value); return contentInfo.valueFormat?.format(value) ?? value;
} else { } else {
return ''; return '';
} }

2
ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts

@ -107,7 +107,7 @@ export interface CellContentFunctionInfo {
export interface CellContentInfo { export interface CellContentInfo {
contentFunction: Observable<CellContentFunctionInfo>; contentFunction: Observable<CellContentFunctionInfo>;
valueFormat?: ValueFormatProcessor valueFormat: ValueFormatProcessor
} }
export type CellStyleFunction = (...args: any[]) => any; export type CellStyleFunction = (...args: any[]) => any;

Loading…
Cancel
Save