Documents and Notes for Clients, Loans and Clients (#1632)
Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
co-authored by
Jose Alberto Hernandez
parent
28d5d7595f
commit
cafe8fa73d
+7
@@ -0,0 +1,7 @@
|
||||
<mifosx-entity-documents-tab [entityType]="entityType" [entityId]="entityId"
|
||||
[entityDocuments]="entityDocuments"
|
||||
[callbackUpload]="uploadDocument"
|
||||
[callbackDownload]="downloadDocument"
|
||||
[callbackDelete]="deleteDocument"
|
||||
>
|
||||
</mifosx-entity-documents-tab>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SavingsDocumentsTabComponent } from './savings-documents-tab.component';
|
||||
|
||||
describe('SavingsDocumentsTabComponent', () => {
|
||||
let component: SavingsDocumentsTabComponent;
|
||||
let fixture: ComponentFixture<SavingsDocumentsTabComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ SavingsDocumentsTabComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SavingsDocumentsTabComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { UploadDocumentDialogComponent } from 'app/clients/clients-view/custom-dialogs/upload-document-dialog/upload-document-dialog.component';
|
||||
import { SavingsService } from 'app/savings/savings.service';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
import { environment } from 'environments/environment';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-savings-documents-tab',
|
||||
templateUrl: './savings-documents-tab.component.html',
|
||||
styleUrls: ['./savings-documents-tab.component.scss']
|
||||
})
|
||||
export class SavingsDocumentsTabComponent implements OnInit {
|
||||
|
||||
/** Stores the resolved savings documents data */
|
||||
entityDocuments: any;
|
||||
/** Stores the saving Account Id */
|
||||
entityId: string;
|
||||
entityType: string = 'savings';
|
||||
|
||||
/**
|
||||
* Retrieves the savings data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private savingsService: SavingsService,
|
||||
private settingsService: SettingsService,
|
||||
public dialog: MatDialog) {
|
||||
this.route.data.subscribe((data: { savingsDocuments: any }) => {
|
||||
this.setSavingsDocumentsData(data.savingsDocuments);
|
||||
});
|
||||
this.entityId = this.route.parent.snapshot.params['savingAccountId'];
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
setSavingsDocumentsData(data: any) {
|
||||
data.forEach((ele: any) => {
|
||||
ele.docUrl = this.settingsService.serverUrl + '/savings/' + ele.parentEntityId + '/documents/' + ele.id + '/attachment?tenantIdentifier=' + environment.fineractPlatformTenantId;
|
||||
if (ele.fileName) {
|
||||
if (ele.fileName.toLowerCase().indexOf('.jpg') !== -1 || ele.fileName.toLowerCase().indexOf('.jpeg') !== -1 || ele.fileName.toLowerCase().indexOf('.png') !== -1) {
|
||||
ele.fileIsImage = true;
|
||||
}
|
||||
}
|
||||
if (ele.type) {
|
||||
if (ele.type.toLowerCase().indexOf('image') !== -1) {
|
||||
ele.fileIsImage = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
this.entityDocuments = data;
|
||||
}
|
||||
|
||||
downloadDocument(parentEntityId: string, documentId: string) {
|
||||
this.savingsService.downloadSavingsDocument(parentEntityId, documentId).subscribe(res => {
|
||||
const url = window.URL.createObjectURL(res);
|
||||
window.open(url);
|
||||
});
|
||||
}
|
||||
|
||||
uploadDocument(formData: FormData): any {
|
||||
return this.savingsService.loadSavingsDocument(this.entityId, formData);
|
||||
}
|
||||
|
||||
deleteDocument(documentId: any) {
|
||||
this.savingsService.deleteSavingsDocument(this.entityId, documentId).subscribe((res: any) => {});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user