feat: upload and delete client image (#1122)

Fixes: #1121
This commit is contained in:
Karan Takalkar
2020-07-17 12:10:57 +05:30
committed by GitHub
parent 9e859afe09
commit a13510dae1
8 changed files with 129 additions and 4 deletions
@@ -0,0 +1,12 @@
<h1 mat-dialog-title>Upload Client Image</h1>
<div>
<mifosx-file-upload flex="60%" (change)="onFileSelect($event)"></mifosx-file-upload>
<mat-dialog-actions align="end">
<button mat-raised-button mat-dialog-close>Cancel</button>
<button mat-raised-button color="primary" [disabled]="!image" [mat-dialog-close]="image">Confirm</button>
</mat-dialog-actions>
</div>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { UploadImageDialogComponent } from './upload-image-dialog.component';
describe('UploadImageDialogComponent', () => {
let component: UploadImageDialogComponent;
let fixture: ComponentFixture<UploadImageDialogComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ UploadImageDialogComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UploadImageDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,33 @@
/** Angular Imports */
import { Component } from '@angular/core';
import { MatDialogRef } from '@angular/material';
/**
* Upload image dialog component.
*/
@Component({
selector: 'mifosx-upload-image-dialog',
templateUrl: './upload-image-dialog.component.html',
styleUrls: ['./upload-image-dialog.component.scss']
})
export class UploadImageDialogComponent {
/** Client Image */
image: File;
/**
* @param {MatDialogRef} dialogRef Component reference to dialog.
*/
constructor(public dialogRef: MatDialogRef<UploadImageDialogComponent>) { }
/**
* Sets file form control value.
* @param {any} $event file change event.
*/
onFileSelect($event: any) {
if ($event.target.files.length > 0) {
this.image = $event.target.files[0];
}
}
}