@@ -47,6 +47,9 @@
|
||||
<button mat-menu-item (click)="doAction('Update Default Savings')"> Update Default Savings </button>
|
||||
<button mat-menu-item (click)="doAction('Transfer Client')"> Transfer Client </button>
|
||||
<button mat-menu-item (click)="doAction('Add Charge')"> Add Charge </button>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
@@ -6,6 +6,9 @@ import { MatDialog } from '@angular/material';
|
||||
|
||||
/** Custom Dialogs */
|
||||
import { UnassignStaffDialogComponent } from './custom-dialogs/unassign-staff-dialog/unassign-staff-dialog.component';
|
||||
import { UploadSignatureDialogComponent } from './custom-dialogs/upload-signature-dialog/upload-signature-dialog.component';
|
||||
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';
|
||||
|
||||
/** Custom Services */
|
||||
@@ -43,10 +46,8 @@ export class ClientsViewComponent implements OnInit {
|
||||
this.clientsService.getClientProfileImage(this.clientViewData.id).subscribe(
|
||||
(base64Image: any) => {
|
||||
this.clientImage = this._sanitizer.bypassSecurityTrustResourceUrl(base64Image);
|
||||
},
|
||||
(error: any) => {}
|
||||
}, (error: any) => {}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,6 +77,16 @@ export class ClientsViewComponent implements OnInit {
|
||||
break;
|
||||
case 'Delete':
|
||||
this.deleteClient();
|
||||
break;
|
||||
case 'View Signature':
|
||||
this.viewSignature();
|
||||
break;
|
||||
case 'Upload Signature':
|
||||
this.uploadSignature();
|
||||
break;
|
||||
case 'Delete Signature':
|
||||
this.deleteSignature();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,4 +132,61 @@ export class ClientsViewComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows client signature in a dialog
|
||||
*/
|
||||
private viewSignature() {
|
||||
this.clientsService.getClientDocuments(this.clientViewData.id).subscribe((documents: any) => {
|
||||
const viewSignatureDialogRef = this.dialog.open(ViewSignatureDialogComponent, {
|
||||
data: {
|
||||
documents: documents,
|
||||
id: this.clientViewData.id
|
||||
}
|
||||
});
|
||||
viewSignatureDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.upload) {
|
||||
this.uploadSignature();
|
||||
} else if (response.delete) {
|
||||
this.deleteSignature();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads client signature
|
||||
*/
|
||||
private uploadSignature() {
|
||||
const uploadSignatureDialogRef = this.dialog.open(UploadSignatureDialogComponent);
|
||||
uploadSignatureDialogRef.afterClosed().subscribe((signature: File) => {
|
||||
if (signature) {
|
||||
this.clientsService.uploadClientSignature(this.clientViewData.id, signature)
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes client signature
|
||||
*/
|
||||
private deleteSignature() {
|
||||
this.clientsService.getClientDocuments(this.clientViewData.id).subscribe((documents: any) => {
|
||||
const deleteSignatureDialogRef = this.dialog.open(DeleteSignatureDialogComponent, {
|
||||
data: documents
|
||||
});
|
||||
deleteSignatureDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.clientsService.deleteClientDocument(this.clientViewData.id, response.id)
|
||||
.subscribe(() => {
|
||||
this.reload();
|
||||
});
|
||||
} else if (response.upload) {
|
||||
this.uploadSignature();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<h1 mat-dialog-title>Delete Client Signature</h1>
|
||||
|
||||
<div *ngIf="signatureId" mat-dialog-content>
|
||||
<p>Are you sure you want to delete this clients signature ?</p>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!signatureId" mat-dialog-content>
|
||||
<p>Client Signature is not provided.</p>
|
||||
</div>
|
||||
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-raised-button mat-dialog-close>Cancel</button>
|
||||
<button mat-raised-button *ngIf="signatureId" color="warn" [mat-dialog-close]="{ delete: true, id: signatureId }">Confirm</button>
|
||||
<button mat-raised-button *ngIf="!signatureId" color="primary" [mat-dialog-close]="{ upload: true }">Upload</button>
|
||||
</mat-dialog-actions>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DeleteSignatureDialogComponent } from './delete-signature-dialog.component';
|
||||
|
||||
describe('DeleteSignatureDialogComponent', () => {
|
||||
let component: DeleteSignatureDialogComponent;
|
||||
let fixture: ComponentFixture<DeleteSignatureDialogComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ DeleteSignatureDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DeleteSignatureDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/** Angular Imports */
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||
|
||||
/**
|
||||
* Delete signature dialog component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-delete-signature-dialog',
|
||||
templateUrl: './delete-signature-dialog.component.html',
|
||||
styleUrls: ['./delete-signature-dialog.component.scss']
|
||||
})
|
||||
export class DeleteSignatureDialogComponent {
|
||||
|
||||
/** Id of client signature in documents */
|
||||
signatureId: any;
|
||||
|
||||
/**
|
||||
* @param {MatDialogRef} dialogRef Component reference to dialog.
|
||||
* @param {any} data Documents data
|
||||
*/
|
||||
constructor(public dialogRef: MatDialogRef<DeleteSignatureDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any[]) {
|
||||
const signature = this.data.find((document: any) => document.name === 'clientSignature') || {};
|
||||
this.signatureId = signature.id;
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<h1 mat-dialog-title>Upload Client Signature</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]="!signature" [mat-dialog-close]="signature">Confirm</button>
|
||||
</mat-dialog-actions>
|
||||
|
||||
</div>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UploadSignatureDialogComponent } from './upload-signature-dialog.component';
|
||||
|
||||
describe('UploadSignatureDialogComponent', () => {
|
||||
let component: UploadSignatureDialogComponent;
|
||||
let fixture: ComponentFixture<UploadSignatureDialogComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ UploadSignatureDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(UploadSignatureDialogComponent);
|
||||
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 signature dialog component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-upload-signature-dialog',
|
||||
templateUrl: './upload-signature-dialog.component.html',
|
||||
styleUrls: ['./upload-signature-dialog.component.scss']
|
||||
})
|
||||
export class UploadSignatureDialogComponent {
|
||||
|
||||
/** Client Signature */
|
||||
signature: File;
|
||||
|
||||
/**
|
||||
* @param {MatDialogRef} dialogRef Component reference to dialog.
|
||||
*/
|
||||
constructor(public dialogRef: MatDialogRef<UploadSignatureDialogComponent>) { }
|
||||
|
||||
/**
|
||||
* Sets file form control value.
|
||||
* @param {any} $event file change event.
|
||||
*/
|
||||
onFileSelect($event: any) {
|
||||
if ($event.target.files.length > 0) {
|
||||
this.signature = $event.target.files[0];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<h1 mat-dialog-title>View Client Signature</h1>
|
||||
|
||||
<div *ngIf="signatureId" mat-dialog-content>
|
||||
<img [src]="signatureImage" alt="Signature">
|
||||
</div>
|
||||
|
||||
<div *ngIf="!signatureId" mat-dialog-content>
|
||||
<p>Client Signature is not provided.</p>
|
||||
</div>
|
||||
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-raised-button mat-dialog-close>Close</button>
|
||||
<button mat-raised-button *ngIf="signatureId" color="warn" [mat-dialog-close]="{ delete: true }">Delete</button>
|
||||
<button mat-raised-button color="primary" [mat-dialog-close]="{ upload: true }">{{ signatureId ? 'Reupload' : 'Upload'}}</button>
|
||||
</mat-dialog-actions>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ViewSignatureDialogComponent } from './view-signature-dialog.component';
|
||||
|
||||
describe('ViewSignatureDialogComponent', () => {
|
||||
let component: ViewSignatureDialogComponent;
|
||||
let fixture: ComponentFixture<ViewSignatureDialogComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ViewSignatureDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ViewSignatureDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/** Angular Imports */
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
|
||||
/** Custom Services */
|
||||
import { ClientsService } from 'app/clients/clients.service';
|
||||
|
||||
/**
|
||||
* View signature dialog component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-view-signature-dialog',
|
||||
templateUrl: './view-signature-dialog.component.html',
|
||||
styleUrls: ['./view-signature-dialog.component.scss']
|
||||
})
|
||||
export class ViewSignatureDialogComponent implements OnInit {
|
||||
|
||||
/** Id of client signature in documents */
|
||||
signatureId: any;
|
||||
/** Signature Image */
|
||||
signatureImage: any;
|
||||
/** Client Id */
|
||||
clientId: any;
|
||||
|
||||
/**
|
||||
* @param {MatDialogRef} dialogRef Component reference to dialog.
|
||||
* @param {any} data Documents data
|
||||
*/
|
||||
constructor(public dialogRef: MatDialogRef<ViewSignatureDialogComponent>,
|
||||
private clientsService: ClientsService,
|
||||
private sanitizer: DomSanitizer,
|
||||
@Inject(MAT_DIALOG_DATA) public data: { documents: any[], id: string }) {
|
||||
const signature = this.data.documents.find((document: any) => document.name === 'clientSignature') || {};
|
||||
this.signatureId = signature.id;
|
||||
this.clientId = this.data.id;
|
||||
console.log(this.clientId);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.signatureId) {
|
||||
this.clientsService.getClientSignatureImage(this.clientId, this.signatureId).subscribe(
|
||||
(base64Image: any) => {
|
||||
this.signatureImage = this.sanitizer.bypassSecurityTrustResourceUrl(base64Image);
|
||||
}, (error: any) => {}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,6 +44,9 @@ import { UndoClientRejectionComponent } from './clients-view/client-actions/undo
|
||||
import { AddClientChargeComponent } from './clients-view/client-actions/add-client-charge/add-client-charge.component';
|
||||
import { ViewChargeComponent } from './clients-view/charges/view-charge/view-charge.component';
|
||||
import { ClientPayChargesComponent } from './clients-view/charges/client-pay-charges/client-pay-charges.component';
|
||||
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';
|
||||
|
||||
|
||||
/**
|
||||
@@ -93,12 +96,18 @@ import { ClientPayChargesComponent } from './clients-view/charges/client-pay-cha
|
||||
UndoClientRejectionComponent,
|
||||
AddClientChargeComponent,
|
||||
ViewChargeComponent,
|
||||
ClientPayChargesComponent
|
||||
ClientPayChargesComponent,
|
||||
ViewSignatureDialogComponent,
|
||||
UploadSignatureDialogComponent,
|
||||
DeleteSignatureDialogComponent
|
||||
],
|
||||
entryComponents: [
|
||||
UploadDocumentDialogComponent,
|
||||
EditNotesDialogComponent,
|
||||
UnassignStaffDialogComponent
|
||||
UnassignStaffDialogComponent,
|
||||
ViewSignatureDialogComponent,
|
||||
UploadSignatureDialogComponent,
|
||||
DeleteSignatureDialogComponent
|
||||
],
|
||||
providers: [DatePipe]
|
||||
|
||||
|
||||
@@ -151,6 +151,18 @@ export class ClientsService {
|
||||
return this.http.skipErrorHandler().get(`/clients/${clientId}/images`, { params: httpParams, responseType: 'text' });
|
||||
}
|
||||
|
||||
uploadClientSignature(clientId: string, signature: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', signature);
|
||||
formData.append('filename', signature.name);
|
||||
return this.http.post(`/clients/${clientId}/images`, formData);
|
||||
}
|
||||
|
||||
getClientSignatureImage(clientId: string, documentId: string) {
|
||||
const httpParams = new HttpParams().set('tenantIdentifier', 'default');
|
||||
return this.http.get(`/clients/${clientId}/documents/${documentId}/attachment`, { params: httpParams, responseType: 'blob' });
|
||||
}
|
||||
|
||||
getClientFamilyMembers(clientId: string) {
|
||||
return this.http.get(`/clients/${clientId}/familymembers`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user