|
|
@ -48,7 +48,7 @@ const DEFAULT_ACTIONS_COLUMN_WIDTH = 150; |
|
|
changeDetection: ChangeDetectionStrategy.OnPush, |
|
|
changeDetection: ChangeDetectionStrategy.OnPush, |
|
|
}) |
|
|
}) |
|
|
export class ExtensibleTableComponent<R = any> implements OnChanges { |
|
|
export class ExtensibleTableComponent<R = any> implements OnChanges { |
|
|
protected _actionsText: string; |
|
|
protected _actionsText!: string; |
|
|
@Input() |
|
|
@Input() |
|
|
set actionsText(value: string) { |
|
|
set actionsText(value: string) { |
|
|
this._actionsText = value; |
|
|
this._actionsText = value; |
|
|
@ -57,13 +57,13 @@ export class ExtensibleTableComponent<R = any> implements OnChanges { |
|
|
return this._actionsText ?? (this.actionList.length > 1 ? 'AbpUi::Actions' : ''); |
|
|
return this._actionsText ?? (this.actionList.length > 1 ? 'AbpUi::Actions' : ''); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Input() data: R[]; |
|
|
@Input() data!: R[]; |
|
|
@Input() list: ListService; |
|
|
@Input() list!: ListService; |
|
|
@Input() recordsTotal: number; |
|
|
@Input() recordsTotal!: number; |
|
|
@Input() set actionsColumnWidth(width: number) { |
|
|
@Input() set actionsColumnWidth(width: number) { |
|
|
this.setColumnWidths(width ? Number(width) : undefined); |
|
|
this.setColumnWidths(width ? Number(width) : undefined); |
|
|
} |
|
|
} |
|
|
@Input() actionsTemplate: TemplateRef<any>; |
|
|
@Input() actionsTemplate?: TemplateRef<any>; |
|
|
|
|
|
|
|
|
@Output() tableActivate = new EventEmitter(); |
|
|
@Output() tableActivate = new EventEmitter(); |
|
|
|
|
|
|
|
|
@ -73,7 +73,7 @@ export class ExtensibleTableComponent<R = any> implements OnChanges { |
|
|
|
|
|
|
|
|
entityPropTypeClasses: EntityPropTypeClass; |
|
|
entityPropTypeClasses: EntityPropTypeClass; |
|
|
|
|
|
|
|
|
readonly columnWidths: number[]; |
|
|
readonly columnWidths!: number[]; |
|
|
|
|
|
|
|
|
readonly propList: EntityPropList<R>; |
|
|
readonly propList: EntityPropList<R>; |
|
|
|
|
|
|
|
|
@ -102,7 +102,7 @@ export class ExtensibleTableComponent<R = any> implements OnChanges { |
|
|
this.setColumnWidths(DEFAULT_ACTIONS_COLUMN_WIDTH); |
|
|
this.setColumnWidths(DEFAULT_ACTIONS_COLUMN_WIDTH); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private setColumnWidths(actionsColumn: number) { |
|
|
private setColumnWidths(actionsColumn: number | undefined) { |
|
|
const widths = [actionsColumn]; |
|
|
const widths = [actionsColumn]; |
|
|
this.propList.forEach(({ value: prop }) => { |
|
|
this.propList.forEach(({ value: prop }) => { |
|
|
widths.push(prop.columnWidth); |
|
|
widths.push(prop.columnWidth); |
|
|
@ -110,8 +110,8 @@ export class ExtensibleTableComponent<R = any> implements OnChanges { |
|
|
(this.columnWidths as any) = widths; |
|
|
(this.columnWidths as any) = widths; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getDate(value: Date, format: string) { |
|
|
private getDate(value: Date | undefined, format: string | undefined) { |
|
|
return value ? formatDate(value, format, this.locale) : ''; |
|
|
return value && format ? formatDate(value, format, this.locale) : ''; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getIcon(value: boolean) { |
|
|
private getIcon(value: boolean) { |
|
|
@ -122,7 +122,7 @@ export class ExtensibleTableComponent<R = any> implements OnChanges { |
|
|
|
|
|
|
|
|
private getEnum(rowValue: any, list: Array<ABP.Option<any>>) { |
|
|
private getEnum(rowValue: any, list: Array<ABP.Option<any>>) { |
|
|
if (!list) return rowValue; |
|
|
if (!list) return rowValue; |
|
|
const { key } = list.find(({ value }) => value === rowValue); |
|
|
const { key } = list.find(({ value }) => value === rowValue) || {}; |
|
|
return key; |
|
|
return key; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -139,7 +139,7 @@ export class ExtensibleTableComponent<R = any> implements OnChanges { |
|
|
case ePropType.DateTime: |
|
|
case ePropType.DateTime: |
|
|
return this.getDate(value, getShortDateShortTimeFormat(this.config)); |
|
|
return this.getDate(value, getShortDateShortTimeFormat(this.config)); |
|
|
case ePropType.Enum: |
|
|
case ePropType.Enum: |
|
|
return this.getEnum(value, prop.enumList); |
|
|
return this.getEnum(value, prop.enumList || []); |
|
|
default: |
|
|
default: |
|
|
return value; |
|
|
return value; |
|
|
// More types can be handled in the future
|
|
|
// More types can be handled in the future
|
|
|
@ -151,7 +151,7 @@ export class ExtensibleTableComponent<R = any> implements OnChanges { |
|
|
ngOnChanges({ data }: SimpleChanges) { |
|
|
ngOnChanges({ data }: SimpleChanges) { |
|
|
if (!data?.currentValue) return; |
|
|
if (!data?.currentValue) return; |
|
|
|
|
|
|
|
|
this.data = data.currentValue.map((record, index) => { |
|
|
this.data = data.currentValue.map((record: any, index: number) => { |
|
|
this.propList.forEach(prop => { |
|
|
this.propList.forEach(prop => { |
|
|
const propData = { getInjected: this.getInjected, record, index } as any; |
|
|
const propData = { getInjected: this.getInjected, record, index } as any; |
|
|
const value = this.getContent(prop.value, propData); |
|
|
const value = this.getContent(prop.value, propData); |
|
|
|