blob: 79c1094c06a92ffbe818abebcb7d5b5a8347916a [file] [log] [blame]
Alex Perryb3168082022-01-22 13:36:13 -08001import {Component} from '@angular/core';
2
Philipp Schrader72beced2022-03-07 05:29:52 -08003type Tab = 'Entry'|'ImportMatchList';
4
Alex Perryb3168082022-01-22 13:36:13 -08005@Component({
6 selector: 'my-app',
7 templateUrl: './app.ng.html',
Philipp Schrader72beced2022-03-07 05:29:52 -08008 styleUrls: ['./common.css']
Alex Perryb3168082022-01-22 13:36:13 -08009})
10export class App {
Philipp Schrader72beced2022-03-07 05:29:52 -080011 tab: Tab = 'Entry';
12
Alex Perryd3ccac92022-03-12 13:48:04 -080013 constructor() {
14 window.addEventListener('beforeunload', (e) => {
15 // Based on https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#example
16 // This combination ensures a dialog will be shown on most browsers.
17 e.preventDefault();
18 e.returnValue = '';
19 });
20 }
21
Philipp Schrader72beced2022-03-07 05:29:52 -080022 tabIs(tab: Tab) {
23 return this.tab == tab;
24 }
25
26 switchTabTo(tab: Tab) {
Alex Perry19a87962022-03-12 13:36:10 -080027 let shouldSwitch = true;
28 if (tab === 'ImportMatchList') {
29 shouldSwitch = window.confirm('Leave data scouting page?');
30 }
31 if (shouldSwitch) {
32 this.tab = tab;
33 }
Philipp Schrader72beced2022-03-07 05:29:52 -080034 }
Alex Perryb3168082022-01-22 13:36:13 -080035}