UI: Add new widget action copy and edit in contect menu
This commit is contained in:
parent
5bef47253e
commit
675b4755ed
@ -1573,7 +1573,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
||||
return dashboardContextActions;
|
||||
}
|
||||
|
||||
prepareWidgetContextMenu(layoutCtx: DashboardPageLayoutContext, widget: Widget): Array<WidgetContextMenuItem> {
|
||||
prepareWidgetContextMenu(layoutCtx: DashboardPageLayoutContext, widget: Widget, isReference: boolean): Array<WidgetContextMenuItem> {
|
||||
const widgetContextActions: Array<WidgetContextMenuItem> = [];
|
||||
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(
|
||||
{
|
||||
|
||||
@ -64,7 +64,7 @@ export interface IDashboardController {
|
||||
dashboardMouseDown($event: Event, layoutCtx: DashboardPageLayoutContext);
|
||||
widgetClicked($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
||||
prepareDashboardContextMenu(layoutCtx: DashboardPageLayoutContext): Array<DashboardContextMenuItem>;
|
||||
prepareWidgetContextMenu(layoutCtx: DashboardPageLayoutContext, widget: Widget): Array<WidgetContextMenuItem>;
|
||||
prepareWidgetContextMenu(layoutCtx: DashboardPageLayoutContext, widget: Widget, isReference: boolean): Array<WidgetContextMenuItem>;
|
||||
copyWidget($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
||||
copyWidgetReference($event: Event, layoutCtx: DashboardPageLayoutContext, widget: Widget);
|
||||
pasteWidget($event: Event, layoutCtx: DashboardPageLayoutContext, pos: WidgetPosition);
|
||||
|
||||
@ -297,8 +297,8 @@ export class DashboardLayoutComponent extends PageComponent implements ILayoutCo
|
||||
return this.layoutCtx.dashboardCtrl.prepareDashboardContextMenu(this.layoutCtx);
|
||||
}
|
||||
|
||||
prepareWidgetContextMenu($event: Event, widget: Widget): Array<WidgetContextMenuItem> {
|
||||
return this.layoutCtx.dashboardCtrl.prepareWidgetContextMenu(this.layoutCtx, widget);
|
||||
prepareWidgetContextMenu($event: Event, widget: Widget, isReference: boolean): Array<WidgetContextMenuItem> {
|
||||
return this.layoutCtx.dashboardCtrl.prepareWidgetContextMenu(this.layoutCtx, widget, isReference);
|
||||
}
|
||||
|
||||
copyWidget($event: Event, widget: Widget) {
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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: `<div class="tb-widget-actions-panel">
|
||||
<button mat-icon-button class="tb-mat-20"
|
||||
*ngIf="container.isReferenceWidget"
|
||||
*ngIf="container.widget.isReference"
|
||||
[fxShow]="container.isEditActionEnabled"
|
||||
(click)="container.onCopyEdit($event)"
|
||||
matTooltip="Edit copy widget"
|
||||
matTooltip="{{ 'widget.edit-copy' | translate }}"
|
||||
matTooltipPosition="above">
|
||||
<tb-icon>mdi:circle-edit-outline</tb-icon>
|
||||
</button>
|
||||
|
||||
@ -72,7 +72,7 @@ export interface DashboardCallbacks {
|
||||
onDashboardMouseDown?: ($event: Event) => void;
|
||||
onWidgetClicked?: ($event: Event, widget: Widget) => void;
|
||||
prepareDashboardContextMenu?: ($event: Event) => Array<DashboardContextMenuItem>;
|
||||
prepareWidgetContextMenu?: ($event: Event, widget: Widget) => Array<WidgetContextMenuItem>;
|
||||
prepareWidgetContextMenu?: ($event: Event, widget: Widget, isReference: boolean) => Array<WidgetContextMenuItem>;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user