Commit 60b7bae0 authored by Romain DELEAU's avatar Romain DELEAU

confirm dialog on close or refresh page

parent e3ba96d3
import { ChangeDetectorRef, Component, ElementRef, ViewChild } from '@angular/core'; import { ChangeDetectorRef, Component, ElementRef, HostListener, ViewChild } from '@angular/core';
import { Mission } from './class/mission/mission'; import { Mission } from './class/mission/mission';
import { Scenario } from './class/scenario/scenario'; import { Scenario } from './class/scenario/scenario';
import { Step } from './class/step/step'; import { Step } from './class/step/step';
...@@ -46,6 +46,13 @@ export class AppComponent { ...@@ -46,6 +46,13 @@ export class AppComponent {
}); });
} }
@HostListener('window:beforeunload', ['$event'])
beforeUnloadHandler(event: any) {
const message = "Êtes vous sûr de vouloir quitter RLG Maker ?\nVous risquez de perdre les données non sauvegardées.";
event.returnValue = message;
return message;
}
downloadFile(): void { downloadFile(): void {
const jsonString = JSON.stringify(this.scenario); const jsonString = JSON.stringify(this.scenario);
const blob = new Blob([jsonString], { type: 'application/json' }); const blob = new Blob([jsonString], { type: 'application/json' });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment