-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added guard, fixed some errors with styling, and added some features (#…
…142) * added guard, fixed some erros with styling, and added some features * fixed code styling error * added modal Deactivate Comp * fixed some erros, added role modal for resetbuttons, and leave page
- Loading branch information
1 parent
be73e0a
commit e160e29
Showing
11 changed files
with
318 additions
and
158 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/app/shell/provider/provider-config/can-leave-guard.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { CanDeactivate } from '@angular/router'; | ||
import { Injectable } from '@angular/core'; | ||
import { ProviderConfigComponent } from './provider-config.component'; | ||
import { MatDialog } from '@angular/material/dialog'; | ||
import { Observable, of } from 'rxjs'; | ||
import { ProviderConfigModalComponent } from './provider-config-modal/provider-config-modal.component'; | ||
|
||
@Injectable() | ||
export class CanDeactivateGuard implements CanDeactivate<ProviderConfigComponent> { | ||
|
||
constructor(private dialog: MatDialog) { | ||
} | ||
|
||
canDeactivate(component: ProviderConfigComponent): Observable<boolean> { | ||
if (component.orgFormGroup.dirty || component.addressFormGroup.dirty || component.photoFormGroup.dirty) { | ||
return this.confirmDialog(); | ||
} | ||
return of(true); | ||
} | ||
|
||
confirmDialog(): Observable<boolean> { | ||
const dialogRef = this.dialog.open(ProviderConfigModalComponent); | ||
return dialogRef.afterClosed(); | ||
} | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
...shell/provider/provider-config/provider-config-modal/provider-config-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1 mat-dialog-title>У вас є не збережені дані, покинути сторінку?</h1> | ||
<div mat-dialog-actions> | ||
<button mat-button (click)="closeModal(false)">Ні</button> | ||
<button mat-button (click)="closeModal(true)">Так</button> | ||
</div> |
Empty file.
25 changes: 25 additions & 0 deletions
25
...ll/provider/provider-config/provider-config-modal/provider-config-modal.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ProviderConfigModalComponent } from './provider-config-modal.component'; | ||
|
||
describe('ProviderConfigModalComponent', () => { | ||
let component: ProviderConfigModalComponent; | ||
let fixture: ComponentFixture<ProviderConfigModalComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ProviderConfigModalComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ProviderConfigModalComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
...p/shell/provider/provider-config/provider-config-modal/provider-config-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Component } from '@angular/core'; | ||
import { MatDialogRef } from '@angular/material/dialog'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-provider-config-modal', | ||
templateUrl: './provider-config-modal.component.html', | ||
styleUrls: ['./provider-config-modal.component.scss'] | ||
}) | ||
export class ProviderConfigModalComponent { | ||
constructor(private dialogRef: MatDialogRef<ProviderConfigModalComponent>) { | ||
} | ||
|
||
closeModal(value: boolean): void { | ||
this.dialogRef.close(value); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.