Browse Source

UI: Disable column sort if enable post processing func

pull/5795/head
ArtemDzhereleiko 5 years ago
parent
commit
d7f9b1d430
  1. 2
      ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.html
  2. 4
      ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.ts
  3. 1
      ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts
  4. 2
      ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.html
  5. 5
      ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts

2
ui-ngx/src/app/modules/home/components/widget/lib/entities-table-widget.component.html

@ -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)">

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

@ -324,6 +324,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
label: 'entityName',
def: 'entityName',
title: entityNameColumnTitle,
sortable: true,
entityKey: {
key: 'name',
type: EntityKeyType.ENTITY_FIELD
@ -347,6 +348,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
label: 'entityLabel',
def: 'entityLabel',
title: entityLabelColumnTitle,
sortable: true,
entityKey: {
key: 'label',
type: EntityKeyType.ENTITY_FIELD
@ -370,6 +372,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
@ -403,6 +406,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') {

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

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

2
ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.html

@ -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)">

5
ui-ngx/src/app/modules/home/components/widget/lib/timeseries-table-widget.component.ts

@ -88,6 +88,7 @@ interface TimeseriesRow {
interface TimeseriesHeader {
index: number;
dataKey: DataKey;
sortable: boolean;
}
interface TimeseriesTableSource {
@ -308,10 +309,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;

Loading…
Cancel
Save