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" <table mat-table [dataSource]="entityDatasource" [trackBy]="trackByEntityId"
matSort [matSortActive]="sortOrderProperty" [matSortDirection]="pageLinkSortDirection()" matSortDisableClear> matSort [matSortActive]="sortOrderProperty" [matSortDirection]="pageLinkSortDirection()" matSortDisableClear>
<ng-container [matColumnDef]="column.def" *ngFor="let column of columns; trackBy: trackByColumnDef;"> <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" <mat-cell *matCellDef="let entity; let row = index"
[innerHTML]="cellContent(entity, column, row)" [innerHTML]="cellContent(entity, column, row)"
[ngStyle]="cellStyle(entity, column, row)"> [ngStyle]="cellStyle(entity, column, row)">

View File

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

View File

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

View File

@ -52,7 +52,7 @@
</mat-cell> </mat-cell>
</ng-container> </ng-container>
<ng-container [matColumnDef]="h.index + ''" *ngFor="let h of source.header; trackBy: trackByColumnIndex;"> <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" <mat-cell *matCellDef="let row; let rowIndex = index"
[innerHTML]="cellContent(source, h.index, row, row[h.index], rowIndex)" [innerHTML]="cellContent(source, h.index, row, row[h.index], rowIndex)"
[ngStyle]="cellStyle(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 { interface TimeseriesHeader {
index: number; index: number;
dataKey: DataKey; dataKey: DataKey;
sortable: boolean;
} }
interface TimeseriesTableSource { interface TimeseriesTableSource {
@ -325,10 +326,12 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
for (let a = 0; a < datasource.dataKeys.length; a++ ) { for (let a = 0; a < datasource.dataKeys.length; a++ ) {
const dataKey = datasource.dataKeys[a]; const dataKey = datasource.dataKeys[a];
const keySettings: TableWidgetDataKeySettings = dataKey.settings; const keySettings: TableWidgetDataKeySettings = dataKey.settings;
const sortable = !dataKey.usePostProcessing;
const index = a + 1; const index = a + 1;
source.header.push({ source.header.push({
index, index,
dataKey dataKey,
sortable
}); });
source.displayedColumns.push(index + ''); source.displayedColumns.push(index + '');
source.rowDataTemplate[dataKey.label] = null; source.rowDataTemplate[dataKey.label] = null;