Browse Source

Merge pull request #11542 from vvlladd28/bug/help-widget/show-action-cell

Fix entity table widgets to correctly process entity type for "show cell button action" function
pull/11592/head
Igor Kulikov 2 years ago
committed by GitHub
parent
commit
132eadc0d6
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      ui-ngx/src/app/modules/home/components/widget/lib/entity/entities-table-widget.component.ts
  2. 3
      ui-ngx/src/app/modules/home/components/widget/lib/table-widget.models.ts

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

@ -49,7 +49,7 @@ import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
import { BehaviorSubject, fromEvent, merge, Observable, Subject } from 'rxjs';
import { emptyPageData, PageData } from '@shared/models/page/page-data';
import { EntityId } from '@shared/models/id/entity-id';
import { entityTypeTranslations } from '@shared/models/entity-type.models';
import { EntityType, entityTypeTranslations } from '@shared/models/entity-type.models';
import { debounceTime, distinctUntilChanged, map, takeUntil } from 'rxjs/operators';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort, SortDirection } from '@angular/material/sort';
@ -408,7 +408,9 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
} as EntityColumn
);
this.contentsInfo.entityType = {
useCellContentFunction: false
useCellContentFunction: true,
cellContentFunction: (entityType: EntityType) =>
entityType ? this.translate.instant(entityTypeTranslations.get(entityType).type) : ''
};
this.stylesInfo.entityType = {
useCellStyleFunction: false
@ -869,9 +871,9 @@ class EntityDatasource implements DataSource<EntityData> {
}
if (datasource.entityType) {
entity.id.entityType = datasource.entityType;
entity.entityType = this.translate.instant(entityTypeTranslations.get(datasource.entityType).type);
entity.entityType = datasource.entityType;
} else {
entity.entityType = '';
entity.entityType = null;
}
this.dataKeys.forEach((dataKey, index) => {
const keyData = data[index].data;

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

@ -25,6 +25,7 @@ import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
import { WidgetContext } from '@home/models/widget-component.models';
import { UtilsService } from '@core/services/utils.service';
import { TranslateService } from '@ngx-translate/core';
import { EntityType } from '@shared/models/entity-type.models';
type ColumnVisibilityOptions = 'visible' | 'hidden' | 'hidden-mobile';
@ -65,7 +66,7 @@ export interface EntityData {
id: EntityId;
entityName: string;
entityLabel?: string;
entityType?: string;
entityType?: EntityType;
actionCellButtons?: TableCellButtonActionDescriptor[];
hasActions?: boolean;
[key: string]: any;

Loading…
Cancel
Save