Browse Source

Removed widget header button action source from HTML page layout (#16339)

* Removed widget header button action source from HTML page layout

* Additional fixes nsd License headers fix
pull/16364/head
Maksym Tsymbarov 2 months ago
committed by GitHub
parent
commit
ce9020a3e1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      ui-ngx/src/app/core/services/dashboard-utils.service.ts
  2. 1
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html
  3. 16
      ui-ngx/src/app/modules/home/components/dashboard-page/edit-widget.component.ts

5
ui-ngx/src/app/core/services/dashboard-utils.service.ts

@ -45,6 +45,7 @@ import {
TargetDevice,
TargetDeviceType,
Widget,
widgetActionSources,
WidgetConfig,
WidgetConfigMode,
WidgetSize,
@ -690,11 +691,13 @@ export class DashboardUtilsService {
};
// Stable per state: an unchanged page keeps its rendered instance, a changed one is re-rendered.
const widgetId = htmlPageWidgetId(stateId);
const actions = {...layout.gridSettings?.htmlPageConfig?.actions};
delete actions[widgetActionSources.headerButton.value];
const config = mergeDeep({},
htmlPageDefaultConfig,
{
settings: layout.gridSettings?.htmlPageConfig?.settings || mergeDeep({} as HtmlContainerWidgetSettings, htmlContainerDefaultSettings),
actions: layout.gridSettings?.htmlPageConfig?.actions
actions
}
);
result.widget = {

1
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html

@ -511,6 +511,7 @@
[widgetLayout]="editingWidgetLayout"
[showLayoutConfig]="showLayoutConfigInEdit(editingLayoutCtx)"
[isDefaultBreakpoint]="editingLayoutCtx?.breakpoint === 'default'"
[isHtmlPage]="isHtml"
(revertWidgetConfig)="onRevertWidgetEdit()"
(applyWidgetConfig)="saveWidget()">
</tb-edit-widget>

16
ui-ngx/src/app/modules/home/components/dashboard-page/edit-widget.component.ts

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import { PageComponent } from '@shared/components/page.component';
import { Store } from '@ngrx/store';
@ -7,7 +8,7 @@ import { AppState } from '@core/core.state';
import { MatDialog } from '@angular/material/dialog';
import { Dashboard, WidgetLayout } from '@shared/models/dashboard.models';
import { IAliasController, IStateController } from '@core/api/widget-api.models';
import { Widget, WidgetConfigMode } from '@shared/models/widget.models';
import { Widget, widgetActionSources, WidgetConfigMode } from '@shared/models/widget.models';
import { WidgetComponentService } from '@home/components/widget/widget-component.service';
import { WidgetConfigComponentData } from '../../models/widget-component.models';
import { isDefined, isDefinedAndNotNull } from '@core/utils';
@ -53,6 +54,10 @@ export class EditWidgetComponent extends PageComponent implements OnInit, OnChan
@coerceBoolean()
isDefaultBreakpoint= true;
@Input()
@coerceBoolean()
isHtmlPage = false;
@Output()
applyWidgetConfig = new EventEmitter<void>();
@ -94,7 +99,7 @@ export class EditWidgetComponent extends PageComponent implements OnInit, OnChan
for (const propName of Object.keys(changes)) {
const change = changes[propName];
if (!change.firstChange && change.currentValue !== change.previousValue) {
if (['widget', 'widgetLayout'].includes(propName)) {
if (['widget', 'widgetLayout', 'isHtmlPage'].includes(propName)) {
reloadConfig = true;
}
}
@ -135,7 +140,10 @@ export class EditWidgetComponent extends PageComponent implements OnInit, OnChan
widgetInfo.typeLatestDataKeySettingsForm : (widgetInfo.latestDataKeySettingsForm || []);
const typeParameters = widgetInfo.typeParameters;
const dataKeySettingsFunction: DataKeySettingsFunction = typeParameters?.dataKeySettingsFunction;
const actionSources = widgetInfo.actionSources;
const actionSources = {...widgetInfo.actionSources};
if (this.isHtmlPage) {
delete actionSources[widgetActionSources.headerButton.value];
}
const isDataEnabled = isDefined(widgetInfo.typeParameters) ? !widgetInfo.typeParameters.useCustomDatasources : true;
this.widgetConfig = {

Loading…
Cancel
Save