-
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.
Merge pull request #38 from cbartel/develop
feat: expedition delete confirm dialog
- Loading branch information
Showing
8 changed files
with
134 additions
and
4 deletions.
There are no files selected for viewing
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
Empty file.
6 changes: 6 additions & 0 deletions
6
webapp/src/app/components/confirm-dialog/confirm-dialog.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,6 @@ | ||
<h1 mat-dialog-title>{{data.title}}</h1> | ||
<div mat-dialog-content>{{data.content}}</div> | ||
<div mat-dialog-actions> | ||
<button mat-raised-button (click)='abort()'>{{data.abortLabel}}</button> | ||
<button mat-raised-button color='warn' (click)='confirm()'>{{data.confirmLabel}}</button> | ||
</div> |
25 changes: 25 additions & 0 deletions
25
webapp/src/app/components/confirm-dialog/confirm-dialog.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 { ConfirmDialogComponent } from './confirm-dialog.component'; | ||
|
||
describe('ConfirmDialogComponent', () => { | ||
let component: ConfirmDialogComponent; | ||
let fixture: ComponentFixture<ConfirmDialogComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ConfirmDialogComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ConfirmDialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
webapp/src/app/components/confirm-dialog/confirm-dialog.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,29 @@ | ||
import { Component, Inject } from '@angular/core'; | ||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; | ||
import { ConfirmDialogData, ConfirmDialogResult } from './confirm-dialog.service'; | ||
|
||
@Component({ | ||
selector: 'app-confirm-dialog', | ||
templateUrl: './confirm-dialog.component.html', | ||
styleUrls: ['./confirm-dialog.component.css'] | ||
}) | ||
export class ConfirmDialogComponent { | ||
constructor( | ||
@Inject(MAT_DIALOG_DATA) public data: ConfirmDialogData, | ||
private dialogRef: MatDialogRef<ConfirmDialogComponent> | ||
) {} | ||
|
||
abort() { | ||
const result: ConfirmDialogResult = { | ||
confirmed: false | ||
}; | ||
this.dialogRef.close(result); | ||
} | ||
|
||
confirm() { | ||
const result: ConfirmDialogResult = { | ||
confirmed: true | ||
}; | ||
this.dialogRef.close(result); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
webapp/src/app/components/confirm-dialog/confirm-dialog.module.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,13 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { ConfirmDialog } from './confirm-dialog.service'; | ||
import { ConfirmDialogComponent } from './confirm-dialog.component'; | ||
import { MatDialogModule } from '@angular/material/dialog'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
|
||
@NgModule({ | ||
imports: [MatDialogModule, MatButtonModule], | ||
declarations: [ConfirmDialogComponent], | ||
providers: [ConfirmDialog], | ||
exports: [] | ||
}) | ||
export class ConfirmDialogModule {} |
27 changes: 27 additions & 0 deletions
27
webapp/src/app/components/confirm-dialog/confirm-dialog.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,27 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { MatDialog } from '@angular/material/dialog'; | ||
import { Observable } from 'rxjs'; | ||
import { ConfirmDialogComponent } from './confirm-dialog.component'; | ||
|
||
export type ConfirmDialogData = { | ||
title: string; | ||
content: string; | ||
confirmLabel: string; | ||
abortLabel: string; | ||
}; | ||
|
||
export type ConfirmDialogResult = { | ||
confirmed: boolean; | ||
}; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ConfirmDialog { | ||
constructor(private dialog: MatDialog) {} | ||
|
||
open(data: ConfirmDialogData): Observable<ConfirmDialogResult> { | ||
const dialogRef = this.dialog.open(ConfirmDialogComponent, { data }); | ||
return dialogRef.afterClosed(); | ||
} | ||
} |
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