Skip to content

Commit 634923f

Browse files
author
Attila Németh
committed
Confirm Element
1 parent 2b87a46 commit 634923f

File tree

6 files changed

+79
-2
lines changed

6 files changed

+79
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@attus/elements",
3-
"version": "11.0.2",
3+
"version": "11.1.0",
44
"peerDependencies": {
55
"@angular/common": "^11.0",
66
"@angular/core": "^11.0"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div mat-dialog-content>
2+
<p class="mat-title">{{ data.question }}</p>
3+
<p class="mat-subheading-2" *ngIf="data.hint !== undefined && data.hint !== ''">
4+
{{ data.hint }}
5+
</p>
6+
</div>
7+
<div mat-dialog-actions>
8+
<button mat-button mat-dialog-close="0">
9+
<mat-icon>close</mat-icon>
10+
{{ data.cancel }}
11+
</button>
12+
<button mat-button mat-dialog-close="1">
13+
<mat-icon>check</mat-icon>
14+
{{ data.ok }}
15+
</button>
16+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { ConfirmComponent } from './confirm.component';
4+
5+
describe('ConfirmComponent', () => {
6+
let component: ConfirmComponent;
7+
let fixture: ComponentFixture<ConfirmComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ ConfirmComponent ]
12+
})
13+
.compileComponents();
14+
});
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(ConfirmComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @file Confirm Component
3+
*
4+
* @author Attila Németh
5+
* @date 11.06.2020
6+
*/
7+
8+
import {Component, Inject} from '@angular/core';
9+
import {MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
10+
11+
export interface ConfirmQuestion {
12+
question: string
13+
hint?: string
14+
cancel?: string
15+
ok?: string
16+
}
17+
18+
@Component({
19+
templateUrl: './confirm.component.html',
20+
})
21+
export class AttusConfirmDialogComponent {
22+
23+
constructor(public dialogRef: MatDialogRef<AttusConfirmDialogComponent>,
24+
@Inject(MAT_DIALOG_DATA) public data: ConfirmQuestion) {
25+
if (data.cancel === undefined) {
26+
data.cancel = 'Cancel';
27+
}
28+
if (data.ok === undefined) {
29+
data.ok = 'OK';
30+
}
31+
}
32+
33+
}

src/lib/elements.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import {MatDialogModule} from '@angular/material/dialog';
88
import {MatButtonModule} from '@angular/material/button';
99

1010
import { AttusElementsLoginDialogComponent } from './components/login/login.component';
11+
import { ConfirmComponent } from './components/confirm/confirm.component';
1112

1213
@NgModule({
1314
declarations: [
14-
AttusElementsLoginDialogComponent
15+
AttusElementsLoginDialogComponent,
16+
ConfirmComponent
1517
],
1618
imports: [
1719
CommonModule,

src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
export * from './lib/elements.module';
66
export * from './lib/components/login/login.component';
7+
export * from './lib/components/confirm/confirm.component';

0 commit comments

Comments
 (0)