Added support of custom title instead of data key label.
This commit is contained in:
parent
1323edf5aa
commit
42f3a2def0
@ -75,6 +75,7 @@ import {
|
|||||||
getColumnWidth,
|
getColumnWidth,
|
||||||
getRowStyleInfo,
|
getRowStyleInfo,
|
||||||
getTableCellButtonActions,
|
getTableCellButtonActions,
|
||||||
|
getHeaderTitle,
|
||||||
noDataMessage,
|
noDataMessage,
|
||||||
prepareTableCellButtonActions,
|
prepareTableCellButtonActions,
|
||||||
RowStyleInfo,
|
RowStyleInfo,
|
||||||
@ -407,11 +408,11 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
|
|||||||
if (this.subscription.alarmSource) {
|
if (this.subscription.alarmSource) {
|
||||||
this.subscription.alarmSource.dataKeys.forEach((alarmDataKey) => {
|
this.subscription.alarmSource.dataKeys.forEach((alarmDataKey) => {
|
||||||
const dataKey: EntityColumn = deepClone(alarmDataKey) as EntityColumn;
|
const dataKey: EntityColumn = deepClone(alarmDataKey) as EntityColumn;
|
||||||
|
const keySettings: TableWidgetDataKeySettings = dataKey.settings;
|
||||||
dataKey.entityKey = dataKeyToEntityKey(alarmDataKey);
|
dataKey.entityKey = dataKeyToEntityKey(alarmDataKey);
|
||||||
dataKey.label = this.utils.customTranslation(dataKey.label, dataKey.label);
|
dataKey.label = this.utils.customTranslation(dataKey.label, dataKey.label);
|
||||||
dataKey.title = dataKey.label;
|
dataKey.title = getHeaderTitle(dataKey, keySettings, this.utils);
|
||||||
dataKey.def = 'def' + this.columns.length;
|
dataKey.def = 'def' + this.columns.length;
|
||||||
const keySettings: TableWidgetDataKeySettings = dataKey.settings;
|
|
||||||
if (dataKey.type === DataKeyType.alarm && !isDefined(keySettings.columnWidth)) {
|
if (dataKey.type === DataKeyType.alarm && !isDefined(keySettings.columnWidth)) {
|
||||||
const alarmField = alarmFields[dataKey.name];
|
const alarmField = alarmFields[dataKey.name];
|
||||||
if (alarmField && alarmField.time) {
|
if (alarmField && alarmField.time) {
|
||||||
|
|||||||
@ -78,6 +78,7 @@ import {
|
|||||||
getColumnDefaultVisibility,
|
getColumnDefaultVisibility,
|
||||||
getColumnSelectionAvailability,
|
getColumnSelectionAvailability,
|
||||||
getColumnWidth,
|
getColumnWidth,
|
||||||
|
getHeaderTitle,
|
||||||
getEntityValue,
|
getEntityValue,
|
||||||
getRowStyleInfo,
|
getRowStyleInfo,
|
||||||
getTableCellButtonActions,
|
getTableCellButtonActions,
|
||||||
@ -426,11 +427,11 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
|
|||||||
}
|
}
|
||||||
dataKeys.push(dataKey);
|
dataKeys.push(dataKey);
|
||||||
|
|
||||||
|
const keySettings: TableWidgetDataKeySettings = dataKey.settings;
|
||||||
dataKey.label = this.utils.customTranslation(dataKey.label, dataKey.label);
|
dataKey.label = this.utils.customTranslation(dataKey.label, dataKey.label);
|
||||||
dataKey.title = dataKey.label;
|
dataKey.title = getHeaderTitle(dataKey, keySettings, this.utils);
|
||||||
dataKey.def = 'def' + this.columns.length;
|
dataKey.def = 'def' + this.columns.length;
|
||||||
dataKey.sortable = !dataKey.usePostProcessing && (!dataKey.aggregationType || dataKey.aggregationType === AggregationType.NONE);
|
dataKey.sortable = !dataKey.usePostProcessing && (!dataKey.aggregationType || dataKey.aggregationType === AggregationType.NONE);
|
||||||
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') {
|
||||||
const entityField = entityFields[dataKey.name];
|
const entityField = entityFields[dataKey.name];
|
||||||
|
|||||||
@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
-->
|
-->
|
||||||
<section class="tb-widget-settings" [formGroup]="entitiesTableKeySettingsForm" fxLayout="column">
|
<section class="tb-widget-settings" [formGroup]="entitiesTableKeySettingsForm" fxLayout="column">
|
||||||
|
<mat-form-field fxFlex class="mat-block">
|
||||||
|
<mat-label translate>widgets.table.custom-title</mat-label>
|
||||||
|
<input matInput formControlName="customTitle">
|
||||||
|
</mat-form-field>
|
||||||
<mat-form-field fxFlex class="mat-block">
|
<mat-form-field fxFlex class="mat-block">
|
||||||
<mat-label translate>widgets.table.column-width</mat-label>
|
<mat-label translate>widgets.table.column-width</mat-label>
|
||||||
<input matInput formControlName="columnWidth">
|
<input matInput formControlName="columnWidth">
|
||||||
|
|||||||
@ -40,6 +40,7 @@ export class EntitiesTableKeySettingsComponent extends WidgetSettingsComponent {
|
|||||||
|
|
||||||
protected defaultSettings(): WidgetSettings {
|
protected defaultSettings(): WidgetSettings {
|
||||||
return {
|
return {
|
||||||
|
customTitle: '',
|
||||||
columnWidth: '0px',
|
columnWidth: '0px',
|
||||||
useCellStyleFunction: false,
|
useCellStyleFunction: false,
|
||||||
cellStyleFunction: '',
|
cellStyleFunction: '',
|
||||||
@ -52,6 +53,7 @@ export class EntitiesTableKeySettingsComponent extends WidgetSettingsComponent {
|
|||||||
|
|
||||||
protected onSettingsSet(settings: WidgetSettings) {
|
protected onSettingsSet(settings: WidgetSettings) {
|
||||||
this.entitiesTableKeySettingsForm = this.fb.group({
|
this.entitiesTableKeySettingsForm = this.fb.group({
|
||||||
|
customTitle: [settings.customTitle, []],
|
||||||
columnWidth: [settings.columnWidth, []],
|
columnWidth: [settings.columnWidth, []],
|
||||||
useCellStyleFunction: [settings.useCellStyleFunction, []],
|
useCellStyleFunction: [settings.useCellStyleFunction, []],
|
||||||
cellStyleFunction: [settings.cellStyleFunction, [Validators.required]],
|
cellStyleFunction: [settings.cellStyleFunction, [Validators.required]],
|
||||||
|
|||||||
@ -43,6 +43,7 @@ export interface TableWidgetSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface TableWidgetDataKeySettings {
|
export interface TableWidgetDataKeySettings {
|
||||||
|
customTitle?: string;
|
||||||
columnWidth?: string;
|
columnWidth?: string;
|
||||||
useCellStyleFunction: boolean;
|
useCellStyleFunction: boolean;
|
||||||
cellStyleFunction?: string;
|
cellStyleFunction?: string;
|
||||||
@ -474,3 +475,10 @@ export function constructTableCssString(widgetConfig: WidgetConfig): string {
|
|||||||
'}';
|
'}';
|
||||||
return cssString;
|
return cssString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getHeaderTitle(dataKey: DataKey, keySettings: TableWidgetDataKeySettings, utils: UtilsService) {
|
||||||
|
if (isDefined(keySettings.customTitle) && isNotEmptyStr(keySettings.customTitle)) {
|
||||||
|
return utils.customTranslation(keySettings.customTitle, keySettings.customTitle);
|
||||||
|
}
|
||||||
|
return dataKey.label;
|
||||||
|
}
|
||||||
|
|||||||
@ -4656,6 +4656,7 @@
|
|||||||
"entity-label-column-title": "Entity label column title",
|
"entity-label-column-title": "Entity label column title",
|
||||||
"display-entity-type": "Display entity type column",
|
"display-entity-type": "Display entity type column",
|
||||||
"default-sort-order": "Default sort order",
|
"default-sort-order": "Default sort order",
|
||||||
|
"custom-title": "Custom header title",
|
||||||
"column-width": "Column width (px or %)",
|
"column-width": "Column width (px or %)",
|
||||||
"default-column-visibility": "Default column visibility",
|
"default-column-visibility": "Default column visibility",
|
||||||
"column-visibility-visible": "Visible",
|
"column-visibility-visible": "Visible",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user