feat(project-editor): warn before leaving with unsaved changes
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { CanDeactivateFn } from '@angular/router';
|
||||
import { ProjectEditorFacade } from '../facade/project-editor.facade';
|
||||
import { ProjectEditorPageComponent } from '../pages/project-editor-page.component';
|
||||
|
||||
export const projectEditorDirtyGuard: CanDeactivateFn<ProjectEditorPageComponent> = () => {
|
||||
const facade = inject(ProjectEditorFacade);
|
||||
if (!facade.dirty()) {
|
||||
return true;
|
||||
}
|
||||
return window.confirm('You have unsaved changes. Leave anyway?');
|
||||
};
|
||||
Reference in New Issue
Block a user