Merge pull request #5795 from ArtemDzhereleiko/task/disable-sort/post-processing-func

[3.3.3] UI: Disable column sort if enable post-processing function
This commit is contained in:
Igor Kulikov 2022-01-12 19:04:00 +02:00 committed by GitHub
commit 3c0bdd9855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 3 deletions

View File

@ -41,7 +41,7 @@
<table mat-table [dataSource]="entityDatasource" [trackBy]="trackByEntityId"
matSort [matSortActive]="sortOrderProperty" [matSortDirection]="pageLinkSortDirection()" matSortDisableClear>
<ng-container [matColumnDef]="column.def" *ngFor="let column of columns; trackBy: trackByColumnDef;">
<mat-header-cell [ngStyle]="headerStyle(column)" *matHeaderCellDef mat-sort-header> {{ column.title }} </mat-header-cell>
<mat-header-cell [ngStyle]="headerStyle(column)" *matHeaderCellDef mat-sort-header [disabled]="!column.sortable"> {{ column.title }} </mat-header-cell>
<mat-cell *matCellDef="let entity; let row = index"
[innerHTML]="cellContent(entity, column, row)"
[ngStyle]="cellStyle(entity, column, row)">

View File

@ -346,6 +346,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
label: 'entityName',
def: 'entityName',
title: entityNameColumnTitle,
sortable: true,
entityKey: {
key: 'name',
type: EntityKeyType.ENTITY_FIELD
@ -369,6 +370,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
label: 'entityLabel',
def: 'entityLabel',
title: entityLabelColumnTitle,
sortable: true,
entityKey: {
key: 'label',
type: EntityKeyType.ENTITY_FIELD
@ -392,6 +394,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
label: 'entityType',
def: 'entityType',
title: this.translate.instant('entity.entity-type'),
sortable: true,
entityKey: {
key: 'entityType',
type: EntityKeyType.ENTITY_FIELD
@ -425,6 +428,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
dataKey.label = this.utils.customTranslation(dataKey.label, dataKey.label);
dataKey.title = dataKey.label;
dataKey.def = 'def' + this.columns.length;
dataKey.sortable = !dataKey.usePostProcessing;
const keySettings: TableWidgetDataKeySettings = dataKey.settings;
if (dataKey.type === DataKeyType.entityField &&
!isDefined(keySettings.columnWidth) || keySettings.columnWidth === '0px') {

View File

@ -73,6 +73,7 @@ export interface EntityData {
export interface EntityColumn extends DataKey {
def: string;
title: string;
sortable: boolean;
entityKey?: EntityKey;
}

View File

@ -52,7 +52,7 @@
</mat-cell>
</ng-container>
<ng-container [matColumnDef]="h.index + ''" *ngFor="let h of source.header; trackBy: trackByColumnIndex;">
<mat-header-cell *matHeaderCellDef mat-sort-header> {{ h.dataKey.label }} </mat-header-cell>
<mat-header-cell *matHeaderCellDef mat-sort-header [disabled]="!h.sortable"> {{ h.dataKey.label }} </mat-header-cell>
<mat-cell *matCellDef="let row; let rowIndex = index"
[innerHTML]="cellContent(source, h.index, row, row[h.index], rowIndex)"
[ngStyle]="cellStyle(source, h.index, row, row[h.index], rowIndex)">

View File

@ -91,6 +91,7 @@ interface TimeseriesRow {
interface TimeseriesHeader {
index: number;
dataKey: DataKey;
sortable: boolean;
}
interface TimeseriesTableSource {
@ -325,10 +326,12 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
for (let a = 0; a < datasource.dataKeys.length; a++ ) {
const dataKey = datasource.dataKeys[a];
const keySettings: TableWidgetDataKeySettings = dataKey.settings;
const sortable = !dataKey.usePostProcessing;
const index = a + 1;
source.header.push({
index,
dataKey
dataKey,
sortable
});
source.displayedColumns.push(index + '');
source.rowDataTemplate[dataKey.label] = null;