@@ -50,6 +50,8 @@
|
||||
<button mat-menu-item (click)="doAction('Upload Signature')"> Upload Signature </button>
|
||||
<button mat-menu-item (click)="doAction('Delete Signature')"> Delete Signature </button>
|
||||
<button mat-menu-item (click)="doAction('View Signature')"> View Signature </button>
|
||||
<button mat-menu-item (click)="doAction('Upload Image')"> Upload Image </button>
|
||||
<span *ngIf="clientImage"><button mat-menu-item (click)="doAction('Delete Image')"> Delete Image </button></span>
|
||||
<span *ngIf="clientViewData.status.value === 'Transfer in progress'"><button mat-menu-item (click)="doAction('Undo Transfer')">Undo Transfer</button></span>
|
||||
<span *ngIf="clientViewData.status.value === 'Transfer in progress'"><button mat-menu-item (click)="doAction('Accept Transfer')">Accept Transfer</button></span>
|
||||
<span *ngIf="clientViewData.status.value === 'Transfer in progress'"><button mat-menu-item (click)="doAction('Reject Transfer')">Reject transfer</button></span>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { UploadSignatureDialogComponent } from './custom-dialogs/upload-signatur
|
||||
import { ViewSignatureDialogComponent } from './custom-dialogs/view-signature-dialog/view-signature-dialog.component';
|
||||
import { DeleteSignatureDialogComponent } from './custom-dialogs/delete-signature-dialog/delete-signature-dialog.component';
|
||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||
import { UploadImageDialogComponent } from './custom-dialogs/upload-image-dialog/upload-image-dialog.component';
|
||||
|
||||
/** Custom Services */
|
||||
import { ClientsService } from '../clients.service';
|
||||
@@ -87,6 +88,12 @@ export class ClientsViewComponent implements OnInit {
|
||||
case 'Delete Signature':
|
||||
this.deleteSignature();
|
||||
break;
|
||||
case 'Upload Image':
|
||||
this.uploadProfileImage();
|
||||
break;
|
||||
case 'Delete Image':
|
||||
this.deleteProfileImage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +167,7 @@ export class ClientsViewComponent implements OnInit {
|
||||
const uploadSignatureDialogRef = this.dialog.open(UploadSignatureDialogComponent);
|
||||
uploadSignatureDialogRef.afterClosed().subscribe((signature: File) => {
|
||||
if (signature) {
|
||||
this.clientsService.uploadClientSignature(this.clientViewData.id, signature)
|
||||
this.clientsService.uploadClientSignatureImage(this.clientViewData.id, signature)
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
@@ -189,4 +196,36 @@ export class ClientsViewComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads the clients image.
|
||||
*/
|
||||
private uploadProfileImage() {
|
||||
const uploadImageDialogRef = this.dialog.open(UploadImageDialogComponent);
|
||||
uploadImageDialogRef.afterClosed().subscribe((image: File) => {
|
||||
if (image) {
|
||||
this.clientsService.uploadClientProfileImage(this.clientViewData.id, image)
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the client image.
|
||||
*/
|
||||
private deleteProfileImage() {
|
||||
const deleteClientImageDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `the profile image of ${this.clientViewData.displayName}` }
|
||||
});
|
||||
deleteClientImageDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.clientsService.deleteClientProfileImage(this.clientViewData.id)
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
@@ -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>
|
||||
+25
@@ -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();
|
||||
});
|
||||
});
|
||||
+33
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,6 +47,7 @@ import { ClientPayChargesComponent } from './clients-view/charges/client-pay-cha
|
||||
import { ViewSignatureDialogComponent } from './clients-view/custom-dialogs/view-signature-dialog/view-signature-dialog.component';
|
||||
import { UploadSignatureDialogComponent } from './clients-view/custom-dialogs/upload-signature-dialog/upload-signature-dialog.component';
|
||||
import { DeleteSignatureDialogComponent } from './clients-view/custom-dialogs/delete-signature-dialog/delete-signature-dialog.component';
|
||||
import { UploadImageDialogComponent } from './clients-view/custom-dialogs/upload-image-dialog/upload-image-dialog.component';
|
||||
|
||||
|
||||
/**
|
||||
@@ -99,7 +100,8 @@ import { DeleteSignatureDialogComponent } from './clients-view/custom-dialogs/de
|
||||
ClientPayChargesComponent,
|
||||
ViewSignatureDialogComponent,
|
||||
UploadSignatureDialogComponent,
|
||||
DeleteSignatureDialogComponent
|
||||
DeleteSignatureDialogComponent,
|
||||
UploadImageDialogComponent
|
||||
],
|
||||
entryComponents: [
|
||||
UploadDocumentDialogComponent,
|
||||
@@ -107,7 +109,8 @@ import { DeleteSignatureDialogComponent } from './clients-view/custom-dialogs/de
|
||||
UnassignStaffDialogComponent,
|
||||
ViewSignatureDialogComponent,
|
||||
UploadSignatureDialogComponent,
|
||||
DeleteSignatureDialogComponent
|
||||
DeleteSignatureDialogComponent,
|
||||
UploadImageDialogComponent
|
||||
],
|
||||
providers: [DatePipe]
|
||||
|
||||
|
||||
@@ -151,7 +151,18 @@ export class ClientsService {
|
||||
return this.http.skipErrorHandler().get(`/clients/${clientId}/images`, { params: httpParams, responseType: 'text' });
|
||||
}
|
||||
|
||||
uploadClientSignature(clientId: string, signature: File) {
|
||||
uploadClientProfileImage(clientId: string, image: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', image);
|
||||
formData.append('filename', 'file');
|
||||
return this.http.post(`/clients/${clientId}/images`, formData);
|
||||
}
|
||||
|
||||
deleteClientProfileImage(clientId: string) {
|
||||
return this.http.delete(`/clients/${clientId}/images`);
|
||||
}
|
||||
|
||||
uploadClientSignatureImage(clientId: string, signature: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', signature);
|
||||
formData.append('filename', signature.name);
|
||||
|
||||
Reference in New Issue
Block a user