Merge pull request #4259 from GabrielInTheWorld/4258
Prevent mistakenly closing the window
This commit is contained in:
commit
eab6e9bfd0
@ -1,5 +1,5 @@
|
|||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
import { Component, OnInit, ViewChild, ElementRef, HostListener } from '@angular/core';
|
||||||
import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser';
|
import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser';
|
||||||
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
||||||
import { MatDialog, MatExpansionPanel, MatSnackBar, MatCheckboxChange, ErrorStateMatcher } from '@angular/material';
|
import { MatDialog, MatExpansionPanel, MatSnackBar, MatCheckboxChange, ErrorStateMatcher } from '@angular/material';
|
||||||
@ -1177,6 +1177,19 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
|
|||||||
this.personalNoteService.setPersonalNoteStar(this.motion.motion, !this.motion.star);
|
this.personalNoteService.setPersonalNoteStar(this.motion.motion, !this.motion.star);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to prevent automatically closing the window/tab,
|
||||||
|
* if the user is editing a motion.
|
||||||
|
*
|
||||||
|
* @param $event The event object from 'onUnbeforeUnload'.
|
||||||
|
*/
|
||||||
|
@HostListener('window:beforeunload', ['$event'])
|
||||||
|
public stopClosing($event: Event): void {
|
||||||
|
if (this.editMotion) {
|
||||||
|
$event.returnValue = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate the state's css class into a color
|
* Translate the state's css class into a color
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user