Browse Source

UI: Display confirm on exit when editing dashboard.

pull/8826/head
Igor Kulikov 3 years ago
parent
commit
1edd2cbaf0
  1. 3
      ui-ngx/src/app/modules/dashboard/dashboard-pages.routing.module.ts
  2. 2
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html
  3. 11
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts
  4. 1
      ui-ngx/src/app/modules/home/pages/customer/customer-routing.module.ts
  5. 2
      ui-ngx/src/app/modules/home/pages/dashboard/dashboard-routing.module.ts
  6. 1
      ui-ngx/src/app/modules/home/pages/edge/edge-routing.module.ts

3
ui-ngx/src/app/modules/dashboard/dashboard-pages.routing.module.ts

@ -25,6 +25,7 @@ import { DashboardUtilsService } from '@core/services/dashboard-utils.service';
import { DashboardResolver } from '@app/modules/home/pages/dashboard/dashboard-routing.module'; import { DashboardResolver } from '@app/modules/home/pages/dashboard/dashboard-routing.module';
import { UtilsService } from '@core/services/utils.service'; import { UtilsService } from '@core/services/utils.service';
import { Widget } from '@app/shared/models/widget.models'; import { Widget } from '@app/shared/models/widget.models';
import { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard';
@Injectable() @Injectable()
export class WidgetEditorDashboardResolver implements Resolve<Dashboard> { export class WidgetEditorDashboardResolver implements Resolve<Dashboard> {
@ -59,6 +60,7 @@ const routes: Routes = [
{ {
path: 'dashboard/:dashboardId', path: 'dashboard/:dashboardId',
component: DashboardPageComponent, component: DashboardPageComponent,
canDeactivate: [ConfirmOnExitGuard],
data: { data: {
breadcrumb: { breadcrumb: {
skip: true skip: true
@ -75,6 +77,7 @@ const routes: Routes = [
{ {
path: 'widget-editor', path: 'widget-editor',
component: DashboardPageComponent, component: DashboardPageComponent,
canDeactivate: [ConfirmOnExitGuard],
data: { data: {
breadcrumb: { breadcrumb: {
skip: true skip: true

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

@ -115,7 +115,7 @@
matTooltip="{{'action.save' | translate}}" matTooltip="{{'action.save' | translate}}"
matTooltipPosition="below"> matTooltipPosition="below">
<mat-icon>done</mat-icon></button> <mat-icon>done</mat-icon></button>
<button fxHide.lt-lg mat-button (click)="saveDashboard()"> <button fxHide.lt-lg mat-stroked-button (click)="saveDashboard()">
<mat-icon>done</mat-icon>{{ 'action.save' | translate }}</button> <mat-icon>done</mat-icon>{{ 'action.save' | translate }}</button>
<button fxHide.gt-md mat-icon-button (click)="toggleDashboardEditMode()" <button fxHide.gt-md mat-icon-button (click)="toggleDashboardEditMode()"
matTooltip="{{'action.cancel' | translate}}" matTooltip="{{'action.cancel' | translate}}"

11
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts

@ -150,6 +150,7 @@ import { tap } from 'rxjs/operators';
import { LayoutFixedSize, LayoutWidthType } from '@home/components/dashboard-page/layout/layout.models'; import { LayoutFixedSize, LayoutWidthType } from '@home/components/dashboard-page/layout/layout.models';
import { TbPopoverComponent } from '@shared/components/popover.component'; import { TbPopoverComponent } from '@shared/components/popover.component';
import { ResizeObserver } from '@juggle/resize-observer'; import { ResizeObserver } from '@juggle/resize-observer';
import { HasDirtyFlag } from '@core/guards/confirm-on-exit.guard';
// @dynamic // @dynamic
@Component({ @Component({
@ -159,7 +160,15 @@ import { ResizeObserver } from '@juggle/resize-observer';
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class DashboardPageComponent extends PageComponent implements IDashboardController, OnInit, AfterViewInit, OnDestroy { export class DashboardPageComponent extends PageComponent implements IDashboardController, HasDirtyFlag, OnInit, AfterViewInit, OnDestroy {
get isDirty(): boolean {
return this.isEdit;
}
set isDirty(value: boolean) {
}
authState: AuthState = getCurrentAuthState(this.store); authState: AuthState = getCurrentAuthState(this.store);

1
ui-ngx/src/app/modules/home/pages/customer/customer-routing.module.ts

@ -251,6 +251,7 @@ const routes: Routes = [
{ {
path: ':dashboardId', path: ':dashboardId',
component: DashboardPageComponent, component: DashboardPageComponent,
canDeactivate: [ConfirmOnExitGuard],
data: { data: {
breadcrumb: { breadcrumb: {
labelFunction: dashboardBreadcumbLabelFunction, labelFunction: dashboardBreadcumbLabelFunction,

2
ui-ngx/src/app/modules/home/pages/dashboard/dashboard-routing.module.ts

@ -32,6 +32,7 @@ import { UserDashboardAction } from '@shared/models/user-settings.models';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
import { getCurrentAuthUser } from '@core/auth/auth.selectors'; import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { ConfirmOnExitGuard } from '@core/guards/confirm-on-exit.guard';
@Injectable() @Injectable()
export class DashboardResolver implements Resolve<Dashboard> { export class DashboardResolver implements Resolve<Dashboard> {
@ -85,6 +86,7 @@ const routes: Routes = [
{ {
path: ':dashboardId', path: ':dashboardId',
component: DashboardPageComponent, component: DashboardPageComponent,
canDeactivate: [ConfirmOnExitGuard],
data: { data: {
breadcrumb: { breadcrumb: {
labelFunction: dashboardBreadcumbLabelFunction, labelFunction: dashboardBreadcumbLabelFunction,

1
ui-ngx/src/app/modules/home/pages/edge/edge-routing.module.ts

@ -241,6 +241,7 @@ const routes: Routes = [
{ {
path: ':dashboardId', path: ':dashboardId',
component: DashboardPageComponent, component: DashboardPageComponent,
canDeactivate: [ConfirmOnExitGuard],
data: { data: {
breadcrumb: { breadcrumb: {
labelFunction: dashboardBreadcumbLabelFunction, labelFunction: dashboardBreadcumbLabelFunction,

Loading…
Cancel
Save