updates for rules screen to can use PendingChangesGuard

This commit is contained in:
Valentin 2022-01-23 17:54:06 +02:00
parent daf90cba6f
commit 387f9a166c
2 changed files with 9 additions and 2 deletions

View File

@ -22,7 +22,7 @@
<div class="editor-container">
<ngx-monaco-editor (init)="onCodeEditorInit($event)" [(ngModel)]="codeEditorText" [options]="editorOptions"></ngx-monaco-editor>
</div>
<div *ngIf="hasChanges && permissionsService.isAdmin()" class="changes-box">
<div *ngIf="changed && permissionsService.isAdmin() && !isLeaving" class="changes-box">
<iqser-icon-button
(action)="save()"
[label]="'rules-screen.save-changes' | translate"

View File

@ -28,6 +28,8 @@ export class RulesScreenComponent implements OnInit {
initialLines: string[] = [];
currentLines: string[] = [];
isLeaving = false;
@ViewChild('fileInput')
private _fileInput: ElementRef;
@ -44,7 +46,12 @@ export class RulesScreenComponent implements OnInit {
private readonly _loadingService: LoadingService,
) {}
get hasChanges(): boolean {
set isLeavingPage(isLeaving: boolean) {
this.isLeaving = isLeaving;
this._changeDetectorRef.detectChanges();
}
get changed(): boolean {
return this.currentLines.toString() !== this.initialLines.toString();
}