Browse Source
Merge pull request #5795 from ArtemDzhereleiko/task/disable-sort/post-processing-func
[3.3.3] UI: Disable column sort if enable post-processing function
pull/5872/head
Igor Kulikov
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
11 additions and
3 deletions
-
ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.html
-
ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts
-
ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts
-
ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.html
-
ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts
|
|
|
@ -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)"> |
|
|
|
|
|
|
|
@ -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') { |
|
|
|
|
|
|
|
@ -73,6 +73,7 @@ export interface EntityData { |
|
|
|
export interface EntityColumn extends DataKey { |
|
|
|
def: string; |
|
|
|
title: string; |
|
|
|
sortable: boolean; |
|
|
|
entityKey?: EntityKey; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -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)"> |
|
|
|
|
|
|
|
@ -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; |
|
|
|
|