@@ -0,0 +1,31 @@
|
|||||||
|
/** Angular Imports */
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
|
||||||
|
|
||||||
|
/** rxjs Imports */
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
/** Custom Services */
|
||||||
|
import { LoansService } from '../loans.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loans notes resolver.
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
export class LoanNotesResolver implements Resolve<Object> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {LoansService} LoansService Loans service.
|
||||||
|
*/
|
||||||
|
constructor(private loansService: LoansService) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Loans data.
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||||
|
const loanId = route.parent.paramMap.get('loanId');
|
||||||
|
return this.loansService.getLoanNotes(loanId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,11 +10,13 @@ import { AddLoanChargeComponent } from './add-loan-charge/add-loan-charge.compon
|
|||||||
import { LoansViewComponent } from './loans-view/loans-view.component';
|
import { LoansViewComponent } from './loans-view/loans-view.component';
|
||||||
import { GeneralTabComponent } from './loans-view/general-tab/general-tab.component';
|
import { GeneralTabComponent } from './loans-view/general-tab/general-tab.component';
|
||||||
import { AccountDetailsComponent } from './loans-view/account-details/account-details.component';
|
import { AccountDetailsComponent } from './loans-view/account-details/account-details.component';
|
||||||
|
import { NotesTabComponent } from './loans-view/notes-tab/notes-tab.component';
|
||||||
|
|
||||||
/** Custom Resolvers */
|
/** Custom Resolvers */
|
||||||
import { LoanChargeTemplateResolver } from './common-resolvers/loan-charge-template.resolver';
|
import { LoanChargeTemplateResolver } from './common-resolvers/loan-charge-template.resolver';
|
||||||
import { LoanDetailsResolver } from './common-resolvers/loan-details.resolver';
|
import { LoanDetailsResolver } from './common-resolvers/loan-details.resolver';
|
||||||
import { LoanDetailsGeneralResolver } from './common-resolvers/loan-details-general.resolver';
|
import { LoanDetailsGeneralResolver } from './common-resolvers/loan-details-general.resolver';
|
||||||
|
import { LoanNotesResolver } from './common-resolvers/loan-notes-resolver';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@@ -45,6 +47,14 @@ const routes: Routes = [
|
|||||||
loanDetailsData: LoanDetailsGeneralResolver
|
loanDetailsData: LoanDetailsGeneralResolver
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'notes',
|
||||||
|
component: NotesTabComponent,
|
||||||
|
data: { title: extract('Notes'), breadcrumb: 'Notes', routeParamBreadcrumb: false },
|
||||||
|
resolve: {
|
||||||
|
loanNotes: LoanNotesResolver
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'add-loan-charge',
|
path: 'add-loan-charge',
|
||||||
component: AddLoanChargeComponent,
|
component: AddLoanChargeComponent,
|
||||||
@@ -64,7 +74,8 @@ const routes: Routes = [
|
|||||||
providers: [
|
providers: [
|
||||||
LoanChargeTemplateResolver,
|
LoanChargeTemplateResolver,
|
||||||
LoanDetailsGeneralResolver,
|
LoanDetailsGeneralResolver,
|
||||||
LoanDetailsResolver
|
LoanDetailsResolver,
|
||||||
|
LoanNotesResolver
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
.tab-container {
|
.tab-container {
|
||||||
|
padding: 1%;
|
||||||
|
margin: 1%;
|
||||||
|
|
||||||
|
h3{
|
||||||
|
margin:1% auto;
|
||||||
|
}
|
||||||
|
.performance-history-container {
|
||||||
|
border: 1px solid;
|
||||||
padding: 1%;
|
padding: 1%;
|
||||||
margin: 1%;
|
margin-bottom: 20px ;
|
||||||
|
}
|
||||||
|
|
||||||
h3{
|
table {
|
||||||
margin:1% auto;
|
width: 100%;
|
||||||
}
|
margin-bottom: 20px;
|
||||||
.performance-history-container {
|
}
|
||||||
border: 1px solid;
|
|
||||||
padding: 1%;
|
|
||||||
margin-bottom: 20px ;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
span {
|
||||||
margin: 0.5em 0;
|
margin: 0.5em 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +1,68 @@
|
|||||||
<mat-card class="loan-card">
|
<mat-card class="loan-card">
|
||||||
<mat-card-header fxLayout="column" class="header">
|
|
||||||
|
|
||||||
<mat-card-title-group class="header-title-group">
|
<mat-card-header fxLayout="column" class="header">
|
||||||
<div class="mat-typography loan-card-title">
|
|
||||||
<mat-card-title>
|
|
||||||
<div fxLayout="row" fxLayout.lt-md="column">
|
|
||||||
<div fxFlex="50%">
|
|
||||||
<h3>
|
|
||||||
<i class="fa fa-stop" matTooltip="{{ loanDetailsData.status.value }}" [ngClass]="loanDetailsData.inArrears?'status-active-overdue':(loanDetailsData.status.code|statusLookup)"></i>
|
|
||||||
Loan Product: {{loanDetailsData.loanProductName}}(#{{loanDetailsData.accountNo}})
|
|
||||||
<br/>
|
|
||||||
<span *ngIf="loanDetailsData.clientName" > Client Name: {{loanDetailsData.clientName}} </span> <br/>
|
|
||||||
<span *ngIf="loanDetailsData.group" > Group Name: {{loanDetailsData.group.name}} </span>
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="loanDetailsData.summary" class="loansOverview mat-typography" fxFlex="50%">
|
<mat-card-title-group class="header-title-group">
|
||||||
<h3> Loan Account OverView </h3>
|
<div class="mat-typography loan-card-title">
|
||||||
<span>Current Balance: {{loanDetailsData.currency.displaySymbol}} {{loanDetailsData.summary.totalOutstanding | number}}</span><br>
|
<mat-card-title>
|
||||||
<span>Arrears By: {{loanDetailsData.summary.totalOverdue | number}}
|
<div fxLayout="row" fxLayout.lt-md="column">
|
||||||
<span *ngIf="!(loanDetailsData.summary.totalOverdue>=0)">Not Provided</span>
|
|
||||||
</span><br>
|
<div fxFlex="50%">
|
||||||
</div>
|
<h3>
|
||||||
</div>
|
<i class="fa fa-stop" matTooltip="{{ loanDetailsData.status.value }}" [ngClass]="loanDetailsData.inArrears?'status-active-overdue':(loanDetailsData.status.code|statusLookup)"></i>
|
||||||
</mat-card-title>
|
Loan Product: {{loanDetailsData.loanProductName}}(#{{loanDetailsData.accountNo}})
|
||||||
|
<br/>
|
||||||
|
<span *ngIf="loanDetailsData.clientName" > Client Name: {{loanDetailsData.clientName}} </span> <br/>
|
||||||
|
<span *ngIf="loanDetailsData.group" > Group Name: {{loanDetailsData.group.name}} </span>
|
||||||
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
</mat-card-title-group>
|
|
||||||
|
|
||||||
<mat-card-actions class="loan-actions">
|
<div *ngIf="loanDetailsData.summary" class="loansOverview mat-typography" fxFlex="50%">
|
||||||
|
<h3> Loan Account OverView </h3>
|
||||||
|
<span>Current Balance: {{loanDetailsData.currency.displaySymbol}} {{loanDetailsData.summary.totalOutstanding | number}}</span><br>
|
||||||
|
<span>Arrears By: {{loanDetailsData.summary.totalOverdue | number}}
|
||||||
|
<span *ngIf="!(loanDetailsData.summary.totalOverdue>=0)">Not Provided</span>
|
||||||
|
</span><br>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ng-container *ngFor="let item of buttons.singlebuttons" class="loan-span">
|
</div>
|
||||||
<button mat-raised-button *mifosxHasPermission="item.taskPermissionName">
|
</mat-card-title>
|
||||||
<i class="{{item.icon}}"></i> {{item.name}} </button>
|
</div>
|
||||||
</ng-container>
|
</mat-card-title-group>
|
||||||
|
|
||||||
<ng-container *ngIf="!(buttons.options === undefined)" class="loan-span">
|
<mat-card-actions class="loan-actions">
|
||||||
<button mat-raised-button [matMenuTriggerFor]="More">More</button>
|
|
||||||
<mat-menu #More="matMenu">
|
|
||||||
<span *ngFor="let item of buttons.options">
|
|
||||||
<button mat-menu-item *mifosxHasPermission="item.taskPermissionName">{{item.name}}</button>
|
|
||||||
</span>
|
|
||||||
</mat-menu>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
</mat-card-actions>
|
<ng-container *ngFor="let item of buttons.singlebuttons" class="loan-span">
|
||||||
|
<button mat-raised-button *mifosxHasPermission="item.taskPermissionName">
|
||||||
|
<i class="{{item.icon}}"></i> {{item.name}} </button>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
</mat-card-header>
|
<ng-container *ngIf="!(buttons.options === undefined)" class="loan-span">
|
||||||
|
<button mat-raised-button [matMenuTriggerFor]="More">More</button>
|
||||||
|
<mat-menu #More="matMenu">
|
||||||
|
<span *ngFor="let item of buttons.options">
|
||||||
|
<button mat-menu-item *mifosxHasPermission="item.taskPermissionName">{{item.name}}</button>
|
||||||
|
</span>
|
||||||
|
</mat-menu>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
</mat-card-actions>
|
||||||
|
|
||||||
|
</mat-card-header>
|
||||||
|
|
||||||
|
<mat-card-content>
|
||||||
|
<nav mat-tab-nav-bar class="navigation-tabs">
|
||||||
|
<a mat-tab-link [routerLink]="['./general']" routerLinkActive #general="routerLinkActive" [active]="general.isActive">
|
||||||
|
General
|
||||||
|
</a>
|
||||||
|
<a mat-tab-link [routerLink]="['./accountdetail']" routerLinkActive #accountdetail="routerLinkActive" [active]="accountdetail.isActive">
|
||||||
|
Account Details
|
||||||
|
</a>
|
||||||
|
<a mat-tab-link *mifosxHasPermission="'READ_LOANNOTE'" [routerLink]="['./notes']" routerLinkActive #notes="routerLinkActive" [active]="notes.isActive">
|
||||||
|
Notes
|
||||||
|
</a>
|
||||||
|
</nav>
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
</mat-card-content>
|
||||||
|
|
||||||
<mat-card-content>
|
|
||||||
<nav mat-tab-nav-bar class="navigation-tabs">
|
|
||||||
<a mat-tab-link [routerLink]="['./general']" routerLinkActive #general="routerLinkActive" [active]="general.isActive">
|
|
||||||
General
|
|
||||||
</a>
|
|
||||||
<a mat-tab-link [routerLink]="['./accountdetail']" routerLinkActive #accountdetail="routerLinkActive" [active]="accountdetail.isActive">
|
|
||||||
Account Details
|
|
||||||
</a>
|
|
||||||
</nav>
|
|
||||||
<router-outlet></router-outlet>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<div class="tab-container mat-typography">
|
||||||
|
<h3>Notes</h3>
|
||||||
|
<div>
|
||||||
|
<form #formRef="ngForm" [formGroup]="noteForm" fxLayout="row" fxLayoutAlign="start baseline" fxLayoutGap="20px"
|
||||||
|
(ngSubmit)="submit()">
|
||||||
|
<mat-form-field fxFlex="calc(90%-20px)">
|
||||||
|
<textarea formControlName="note" matInput placeholder="Write a note ...."></textarea>
|
||||||
|
</mat-form-field>
|
||||||
|
<button mat-raised-button fxFlex color="primary" [disabled]="!noteForm.valid">
|
||||||
|
<fa-icon icon="plus"></fa-icon> Add
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<mat-list>
|
||||||
|
<mat-list-item *ngFor="let loanNote of loanNotes; let i=index;">
|
||||||
|
<fa-icon icon="sticky-note" matListIcon></fa-icon>
|
||||||
|
<h3 matLine>{{loanNote.note}} </h3>
|
||||||
|
<p matLine>
|
||||||
|
<span>Created by: {{loanNote.createdByUsername}}</span><br />
|
||||||
|
<span>Date: {{loanNote.createdOn | date}}</span>
|
||||||
|
</p>
|
||||||
|
<div fxLayout="row" fxLayoutAlign="flex-start">
|
||||||
|
<button mat-button color="primary" (click)="editNote(loanNote.id,loanNote.note,i)">
|
||||||
|
<fa-icon icon="edit"></fa-icon>
|
||||||
|
</button>
|
||||||
|
<button mat-button color="warn" (click)="deleteNote(loanNote.id,i)">
|
||||||
|
<fa-icon icon="trash"></fa-icon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</mat-list-item>
|
||||||
|
</mat-list>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
.tab-container {
|
||||||
|
padding: 1%;
|
||||||
|
margin: 1%;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { NotesTabComponent } from './notes-tab.component';
|
||||||
|
|
||||||
|
describe('NotesTabComponent', () => {
|
||||||
|
let component: NotesTabComponent;
|
||||||
|
let fixture: ComponentFixture<NotesTabComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ NotesTabComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(NotesTabComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { MatDialog } from '@angular/material';
|
||||||
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||||
|
|
||||||
|
/** Custom Components */
|
||||||
|
import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component';
|
||||||
|
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
|
||||||
|
|
||||||
|
/** Custom Services */
|
||||||
|
import { LoansService } from '../../loans.service';
|
||||||
|
import { AuthenticationService } from '../../../core/authentication/authentication.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-notes-tab',
|
||||||
|
templateUrl: './notes-tab.component.html',
|
||||||
|
styleUrls: ['./notes-tab.component.scss']
|
||||||
|
})
|
||||||
|
export class NotesTabComponent implements OnInit {
|
||||||
|
|
||||||
|
loanId: string;
|
||||||
|
username: string;
|
||||||
|
loanNotes: any;
|
||||||
|
noteForm: FormGroup;
|
||||||
|
@ViewChild('formRef') formRef: any;
|
||||||
|
|
||||||
|
|
||||||
|
constructor(private route: ActivatedRoute,
|
||||||
|
private formBuilder: FormBuilder,
|
||||||
|
private loansService: LoansService,
|
||||||
|
private authenticationService: AuthenticationService,
|
||||||
|
private dialog: MatDialog) {
|
||||||
|
const savedCredentials = this.authenticationService.getCredentials();
|
||||||
|
this.username = savedCredentials.username;
|
||||||
|
this.loanId = this.route.parent.snapshot.params['loanId'];
|
||||||
|
this.route.data.subscribe((data: { loanNotes: any }) => {
|
||||||
|
this.loanNotes = data.loanNotes;
|
||||||
|
console.log('notes: ', this.loanNotes);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.createNoteForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
createNoteForm() {
|
||||||
|
this.noteForm = this.formBuilder.group({
|
||||||
|
'note': ['', Validators.required]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
submit() {
|
||||||
|
this.loansService.createLoanNote(this.loanId, this.noteForm.value).subscribe((response: any) => {
|
||||||
|
this.loanNotes.push({
|
||||||
|
id: response.resourceId,
|
||||||
|
createdByUsername: this.username,
|
||||||
|
createdOn: new Date(),
|
||||||
|
note: this.noteForm.value.note
|
||||||
|
});
|
||||||
|
this.formRef.resetForm();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
editNote(noteId: string, noteContent: string, index: number) {
|
||||||
|
const editNoteDialogRef = this.dialog.open(FormDialogComponent, {
|
||||||
|
data: { formfields: [{
|
||||||
|
controlName: 'note',
|
||||||
|
required: true,
|
||||||
|
value: noteContent,
|
||||||
|
controlType: 'input',
|
||||||
|
label: 'Note'
|
||||||
|
}],
|
||||||
|
layout: {
|
||||||
|
columns: 1,
|
||||||
|
addButtonText: 'Confirm'
|
||||||
|
},
|
||||||
|
title: 'Edit Note'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
editNoteDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
|
if (response.data) {
|
||||||
|
this.loansService.editLoanNote(this.loanId, noteId, response.data.value).subscribe(() => {
|
||||||
|
this.loanNotes[index].note = response.data.value.note;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteNote(noteId: string, index: number) {
|
||||||
|
const deleteNoteDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||||
|
data: { deleteContext: `Note id:${noteId}` }
|
||||||
|
});
|
||||||
|
deleteNoteDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
|
if (response.delete) {
|
||||||
|
this.loansService.deleteLoanNote(this.loanId, noteId)
|
||||||
|
.subscribe(() => {
|
||||||
|
this.loanNotes.splice(index, 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import { AddLoanChargeComponent } from './add-loan-charge/add-loan-charge.compon
|
|||||||
import { LoansViewComponent } from './loans-view/loans-view.component';
|
import { LoansViewComponent } from './loans-view/loans-view.component';
|
||||||
import { GeneralTabComponent } from './loans-view/general-tab/general-tab.component';
|
import { GeneralTabComponent } from './loans-view/general-tab/general-tab.component';
|
||||||
import { AccountDetailsComponent } from './loans-view/account-details/account-details.component';
|
import { AccountDetailsComponent } from './loans-view/account-details/account-details.component';
|
||||||
|
import { NotesTabComponent } from './loans-view/notes-tab/notes-tab.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loans Module
|
* Loans Module
|
||||||
@@ -26,6 +27,7 @@ import { AccountDetailsComponent } from './loans-view/account-details/account-de
|
|||||||
LoansViewComponent,
|
LoansViewComponent,
|
||||||
GeneralTabComponent,
|
GeneralTabComponent,
|
||||||
AccountDetailsComponent,
|
AccountDetailsComponent,
|
||||||
|
NotesTabComponent,
|
||||||
],
|
],
|
||||||
providers: [DatePipe],
|
providers: [DatePipe],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,4 +33,41 @@ export class LoansService {
|
|||||||
return this.http.get(`/loans/${loanId}`);
|
return this.http.get(`/loans/${loanId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param loanId Loan Id
|
||||||
|
* @returns The notes for particular loan
|
||||||
|
*/
|
||||||
|
getLoanNotes(loanId: string): Observable<any> {
|
||||||
|
return this.http.get(`/loans/${loanId}/notes`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a note to the particular Loan Id
|
||||||
|
* @param loanId Loan ID
|
||||||
|
* @param noteData Note Data to be added
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
createLoanNote(loanId: string, noteData: any): Observable<any> {
|
||||||
|
return this.http.post(`/loans/${loanId}/notes`, noteData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edits the Loan Note
|
||||||
|
* @param loanId Loan ID
|
||||||
|
* @param noteId Note ID
|
||||||
|
* @param noteData Note Data
|
||||||
|
*/
|
||||||
|
editLoanNote(loanId: string, noteId: string, noteData: any) {
|
||||||
|
return this.http.put(`/loans/${loanId}/notes/${noteId}`, noteData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the particular Note
|
||||||
|
* @param loanId Loan ID
|
||||||
|
* @param noteId Note ID
|
||||||
|
*/
|
||||||
|
deleteLoanNote(loanId: string, noteId: string) {
|
||||||
|
return this.http.delete(`/loans/${loanId}/notes/${noteId}`);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user