jleibl_hotel_manager #20
@ -3,11 +3,11 @@ import { HotelFormComponent } from './hotel-form/hotel-form.component';
|
|||||||
import { HotelDetailsComponent } from './hotel-details/hotel-details.component';
|
import { HotelDetailsComponent } from './hotel-details/hotel-details.component';
|
||||||
|
|
||||||
export const formGuard: CanDeactivateFn<HotelFormComponent | HotelDetailsComponent> = (component: HotelFormComponent | HotelDetailsComponent, currentRoute, currentState, nextState) => {
|
export const formGuard: CanDeactivateFn<HotelFormComponent | HotelDetailsComponent> = (component: HotelFormComponent | HotelDetailsComponent, currentRoute, currentState, nextState) => {
|
||||||
console.log(component)
|
const hasUnsavedChanges =
|
||||||
if (component instanceof HotelFormComponent && component.form?.dirty) {
|
(component instanceof HotelFormComponent && component.form?.dirty) ||
|
||||||
return confirm('You have unsaved changes. Do you really want to leave?');
|
(component instanceof HotelDetailsComponent && component.hotelForm?.form?.dirty);
|
||||||
}
|
|
||||||
else if (component instanceof HotelDetailsComponent && component.hotelForm?.form?.dirty) {
|
if (hasUnsavedChanges) {
|
||||||
return confirm('You have unsaved changes. Do you really want to leave?');
|
return confirm('You have unsaved changes. Do you really want to leave?');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user