diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts index 311fd6c258..3eb29babb2 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts @@ -1573,7 +1573,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC return dashboardContextActions; } - prepareWidgetContextMenu(layoutCtx: DashboardPageLayoutContext, widget: Widget): Array { + prepareWidgetContextMenu(layoutCtx: DashboardPageLayoutContext, widget: Widget, isReference: boolean): Array { const widgetContextActions: Array = []; if (this.isEdit && !this.isEditingWidget) { widgetContextActions.push( @@ -1586,6 +1586,18 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC icon: 'edit' } ); + if (isReference) { + widgetContextActions.push( + { + action: (event, currentWidget) => { + this.copyEditWidget(event, layoutCtx, currentWidget); + }, + enabled: true, + value: 'widget.copy-edit', + icon: 'edit' + } + ); + } if (!this.widgetEditMode) { widgetContextActions.push( { diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts index 3b4e40fd8f..ca7da5a611 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts @@ -64,7 +64,7 @@ export interface IDashboardController { dashboardMouseDown($event: Event, layoutCtx: DashboardPageLayoutContext); widgetClicked($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget); prepareDashboardContextMenu(layoutCtx: DashboardPageLayoutContext): Array; - prepareWidgetContextMenu(layoutCtx: DashboardPageLayoutContext, widget: Widget): Array; + prepareWidgetContextMenu(layoutCtx: DashboardPageLayoutContext, widget: Widget, isReference: boolean): Array; copyWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget); copyWidgetReference($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget); pasteWidget($event: Event, layoutCtx: DashboardPageLayoutContext, pos: WidgetPosition); diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts index b5c1565ef4..38c4b99b49 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/layout/dashboard-layout.component.ts @@ -297,8 +297,8 @@ export class DashboardLayoutComponent extends PageComponent implements ILayoutCo return this.layoutCtx.dashboardCtrl.prepareDashboardContextMenu(this.layoutCtx); } - prepareWidgetContextMenu($event: Event, widget: Widget): Array { - return this.layoutCtx.dashboardCtrl.prepareWidgetContextMenu(this.layoutCtx, widget); + prepareWidgetContextMenu($event: Event, widget: Widget, isReference: boolean): Array { + return this.layoutCtx.dashboardCtrl.prepareWidgetContextMenu(this.layoutCtx, widget, isReference); } copyWidget($event: Event, widget: Widget) { diff --git a/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts b/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts index 136429ced4..ffb804a288 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts @@ -421,7 +421,7 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo private openWidgetContextMenu($event: MouseEvent, widget: DashboardWidget) { if (this.callbacks && this.callbacks.prepareWidgetContextMenu) { - const items = this.callbacks.prepareWidgetContextMenu($event, widget.widget); + const items = this.callbacks.prepareWidgetContextMenu($event, widget.widget, widget.isReference); if (items && items.length) { $event.preventDefault(); $event.stopPropagation(); diff --git a/ui-ngx/src/app/modules/home/components/widget/widget-container.component.ts b/ui-ngx/src/app/modules/home/components/widget/widget-container.component.ts index 7ca05f9a7c..75bfb193eb 100644 --- a/ui-ngx/src/app/modules/home/components/widget/widget-container.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/widget-container.component.ts @@ -293,7 +293,7 @@ export class WidgetContainerComponent extends PageComponent implements OnInit, O this.cd.markForCheck(); }, functionBefore: () => { - this.isReferenceWidget = this.dashboardUtils.isReferenceWidget( + this.widget.isReference = this.dashboardUtils.isReferenceWidget( this.widget.widgetContext.dashboard.stateController.dashboardCtrl.dashboardCtx.getDashboard(), this.widget.widgetId); componentRef.instance.cd.detectChanges(); } @@ -345,10 +345,10 @@ export class WidgetContainerComponent extends PageComponent implements OnInit, O @Component({ template: `
diff --git a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts index 78def5126f..efdc6e3a9a 100644 --- a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts +++ b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts @@ -72,7 +72,7 @@ export interface DashboardCallbacks { onDashboardMouseDown?: ($event: Event) => void; onWidgetClicked?: ($event: Event, widget: Widget) => void; prepareDashboardContextMenu?: ($event: Event) => Array; - prepareWidgetContextMenu?: ($event: Event, widget: Widget) => Array; + prepareWidgetContextMenu?: ($event: Event, widget: Widget, isReference: boolean) => Array; } export interface IDashboardComponent { @@ -344,6 +344,7 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget { private selectedCallback: (selected: boolean) => void = () => {}; isFullscreen = false; + isReference = false; color: string; backgroundColor: string; diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index c799473714..f966313d6d 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -5600,6 +5600,8 @@ "remove": "Remove widget", "delete": "Delete widget", "edit": "Edit widget", + "edit-copy": "Edit copy widget", + "copy-edit": "Copy and edit", "remove-widget-title": "Are you sure you want to remove the widget '{{widgetTitle}}'?", "remove-widget-text": "After the confirmation the widget and all related data will become unrecoverable.", "timeseries": "Time series",