add confirmModal + float format pipe + moved a component

This commit is contained in:
X4Lo committed 2024-05-10 09:39:13 +01:00
1 parent 49f8cd601b
commit 1361fc7b18
12 files changed
+112 -31

No files matched your search

@@ -0,0 +1,19 @@
<div class="card border-top border-3 border-{{type}} rounded-0" style="margin-bottom: 0 !important;">
<div class="modal-header card-header py-3 px-4">
<h5 class="mb-0 text-{{type}}">{{title}}</h5>
<button type="button" class="btn-close" (click)="onClose()" aria-label="Close"></button>
</div>
<div class="card-body p-4">
<form class="row g-3">
<div class="col-md-12">
<p style="text-align: justify;">{{message}}</p>
</div>
<div class="col-md-12">
<div class="d-flex justify-content-end gap-3">
<button type="button" class="btn btn-{{type}} px-4 rounded-0" (click)="onConfirm()">Confirm</button>
<button type="button" class="btn btn-secondary px-4 rounded-0" (click)="onClose()">Cancel</button>
</div>
</div>
</form>
</div>
</div>
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ConfirmModalComponent } from './confirm-modal.component';
describe('ConfirmModalComponent', () => {
let component: ConfirmModalComponent;
let fixture: ComponentFixture<ConfirmModalComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ConfirmModalComponent]
})
.compileComponents();
fixture = TestBed.createComponent(ConfirmModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,34 @@
import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { FormBuilder } from '@angular/forms';
@Component({
selector: 'app-confirm-modal',
templateUrl: './confirm-modal.component.html',
styleUrl: './confirm-modal.component.css',
})
export class ConfirmModalComponent implements OnInit {
title: string = 'Confirm your action';
message: string = 'Are you sure?';
type: string = 'dangger';
constructor(
public dialogRef: MatDialogRef<ConfirmModalComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) {}
ngOnInit() {
if (this.data == null) return;
this.title = this.data.title;
this.message = this.data.message;
this.type = this.data.type;
}
onConfirm(): void {
this.dialogRef.close({ confirmed: true });
}
onClose(): void {
this.dialogRef.close();
}
}