From b0fa0f231996e251b46e2b56f9f93dc7571e3617 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+nikonratm@users.noreply.github.com> Date: Mon, 25 Jan 2021 22:44:26 -0800 Subject: [PATCH] Settings navigation warning dialog --- src-ui/src/app/app-routing.module.ts | 7 +++-- .../confirm-dialog.component.html | 6 ++-- .../confirm-dialog.component.ts | 21 +++++++++++--- .../manage/settings/settings.component.ts | 10 +++---- src-ui/src/app/guards/dirty-form.guard.ts | 29 +++++++++++++++++++ 5 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 src-ui/src/app/guards/dirty-form.guard.ts diff --git a/src-ui/src/app/app-routing.module.ts b/src-ui/src/app/app-routing.module.ts index 27f0629b4..8af68221b 100644 --- a/src-ui/src/app/app-routing.module.ts +++ b/src-ui/src/app/app-routing.module.ts @@ -11,6 +11,7 @@ import { SettingsComponent } from './components/manage/settings/settings.compone import { TagListComponent } from './components/manage/tag-list/tag-list.component'; import { NotFoundComponent } from './components/not-found/not-found.component'; import { SearchComponent } from './components/search/search.component'; +import { FormDirtyGuard } from './guards/dirty-form.guard'; const routes: Routes = [ {path: '', redirectTo: 'dashboard', pathMatch: 'full'}, @@ -20,13 +21,13 @@ const routes: Routes = [ {path: 'view/:id', component: DocumentListComponent }, {path: 'search', component: SearchComponent }, {path: 'documents/:id', component: DocumentDetailComponent }, - + {path: 'tags', component: TagListComponent }, {path: 'documenttypes', component: DocumentTypeListComponent }, {path: 'correspondents', component: CorrespondentListComponent }, {path: 'logs', component: LogsComponent }, - {path: 'settings', component: SettingsComponent }, - ]}, + {path: 'settings', component: SettingsComponent, canDeactivate: [FormDirtyGuard] }, + ]}, {path: '404', component: NotFoundComponent}, {path: '**', redirectTo: '/404', pathMatch: 'full'} diff --git a/src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.html b/src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.html index 8a8a297d9..780ae6891 100644 --- a/src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.html +++ b/src-ui/src/app/components/common/confirm-dialog/confirm-dialog.component.html @@ -1,6 +1,6 @@
{{message}}