jleibl_hotel_manager #20

Open
jleibl wants to merge 5 commits from jleibl_hotel_manager into main
Showing only changes of commit a6829fc3f5 - Show all commits

View File

@ -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?');
} }