refactor: clients module (#1207)

See: #1196
This commit is contained in:
Karan Takalkar
2020-08-15 19:24:04 +05:30
committed by GitHub
parent 9861182b7d
commit c42e128b09
32 changed files with 473 additions and 249 deletions
@@ -1,12 +1,17 @@
<div class="tab-container mat-typography">
<h3>Address</h3>
<div fxLayout="row" fxLayoutAlign="flex-end">
<button mat-raised-button color="primary" (click)="addAddress()">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp;Add
</button>
</div>
<mat-accordion>
<mat-expansion-panel *ngFor="let address of clientAddressData;index as i" class="address">
<mat-expansion-panel-header>
<mat-panel-title>
{{address.addressType}}
@@ -15,13 +20,16 @@
{{address.relationship}}
</mat-panel-description>
</mat-expansion-panel-header>
<mat-divider [inset]="true"></mat-divider>
<div class="address-actions" fxLayout="row" fxLayoutAlign="flex-end center">
<button mat-button color="primary" (click)="editAddress(address,i)">
<fa-icon icon="edit"></fa-icon>
</button>
<mat-slide-toggle [checked]="address.isActive" (change)="toogleAddress(address)"></mat-slide-toggle>
<mat-slide-toggle [checked]="address.isActive" (change)="toggleAddress(address)"></mat-slide-toggle>
</div>
<p>
<span *ngIf="isFieldEnabled('street')">Street : {{address.street}}<br /></span>
<span *ngIf="isFieldEnabled('addressLine1')">Address Line 1 : {{address.addressLine1}}<br /></span>
@@ -36,6 +44,9 @@
<span *ngIf="isFieldEnabled('postalCode')">Postal Code : {{address.postalCode}}<br /></span>
<span *ngIf="isFieldEnabled('isActive')">Active Status : {{address.isActive}}<br /></span>
</p>
</mat-expansion-panel>
</mat-accordion>
</div>
@@ -1,22 +1,22 @@
.tab-container {
padding:1%;
margin: 1%;
.address {
.address-actions{
margin-top: 1%;
button{
margin-right: 1%;
}
}
h3 {
margin: 1% auto;
}
p {
line-height: 30px;
margin-left: 2%;
padding:1%;
margin: 1%;
.address {
.address-actions{
margin-top: 1%;
button{
margin-right: 1%;
}
}
h3 {
margin: 1% auto;
}
p {
line-height: 30px;
margin-left: 2%;
}
}
}
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
/** Angular Imports */
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MatDialog } from '@angular/material';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
@@ -11,21 +12,33 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen
/** Custom Services */
import { ClientsService } from '../../clients.service';
/**
* Clients Address Tab Component
*/
@Component({
selector: 'mifosx-address-tab',
templateUrl: './address-tab.component.html',
styleUrls: ['./address-tab.component.scss']
})
export class AddressTabComponent implements OnInit {
export class AddressTabComponent {
/** Client Address Data */
clientAddressData: any;
/** Client Address Field Config */
clientAddressFieldConfig: any;
/** Client Address Template */
clientAddressTemplate: any;
/** Client Id */
clientId: string;
/**
* @param {ActivatedRoute} route Activated Route
* @param {ClientsService} clientService Clients Service
* @param {MatDialog} dialog Mat Dialog
*/
constructor(private route: ActivatedRoute,
private clientService: ClientsService,
private dialog: MatDialog) {
private clientService: ClientsService,
private dialog: MatDialog) {
this.route.data.subscribe((data: {
clientAddressData: any,
clientAddressFieldConfig: any,
@@ -38,11 +51,10 @@ export class AddressTabComponent implements OnInit {
});
}
ngOnInit() {
}
/**
* Adds a client address.
*/
addAddress() {
const data = {
title: 'Add Client Address',
formfields: this.getAddressFormFields('add')
@@ -63,6 +75,11 @@ export class AddressTabComponent implements OnInit {
});
}
/**
* Edits an existing address.
* @param {any} address Client address
* @param {number} index address index
*/
editAddress(address: any, index: number) {
const data = {
title: 'Edit Client Address',
@@ -85,7 +102,11 @@ export class AddressTabComponent implements OnInit {
});
}
toogleAddress(address: any) {
/**
* Toggles address activity.
* @param {any} address Client Address
*/
toggleAddress(address: any) {
const addressData = {
'addressId': address.addressId,
'isActive': address.isActive ? false : true
@@ -95,14 +116,28 @@ export class AddressTabComponent implements OnInit {
});
}
/**
* Checks if field is enabled in address config.
* @param {any} fieldName Field Name
*/
isFieldEnabled(fieldName: any) {
return (this.clientAddressFieldConfig.find((fieldObj: any) => fieldObj.field === fieldName)).is_enabled;
}
/**
* Find Pipe doesn't work with accordian
* @param {any} fieldName Field Name
* @param {any} fieldId Field Id
*/
getSelectedValue(fieldName: any, fieldId: any) {
return (this.clientAddressTemplate[fieldName].find((fieldObj: any) => fieldObj.id === fieldId));
}
/**
* Returns address form fields for form dialog.
* @param {string} formType Form Type
* @param {any} address Address
*/
getAddressFormFields(formType?: string, address?: any) {
let formfields: FormfieldBase[] = [];
if (formType === 'add') {
@@ -1,34 +1,38 @@
<div class="tab-container mat-typography">
<div class="container mat-typography">
<form [formGroup]="transactionForm" (ngSubmit)="submit()">
<mat-card>
<div fxLayout="column">
<form [formGroup]="transactionForm" (ngSubmit)="submit()">
<mat-form-field>
<mat-label> Amount </mat-label>
<input matInput required autofocus formControlName="amount">
<mat-error *ngIf="transactionForm.controls.amount.hasError('required')">
Amount <strong>is required</strong>
</mat-error>
</mat-form-field>
<div fxLayout="column">
<mat-form-field>
<mat-label> Amount </mat-label>
<input matInput required autofocus formControlName="amount">
<mat-error *ngIf="transactionForm.controls.amount.hasError('required')">
Amount <strong>is required</strong>
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label> Transaction date </mat-label>
<input matInput [min]="minDate" [matDatepicker]="transactionDatePicker" required formControlName="transactionDate">
<mat-datepicker-toggle matSuffix [for]="transactionDatePicker"></mat-datepicker-toggle>
<mat-datepicker #transactionDatePicker></mat-datepicker>
<mat-error *ngIf="transactionForm.controls.transactionDate.hasError('required')">
Transaction date <strong>is required</strong>
</mat-error>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="5px">
<button type="button" mat-raised-button [routerLink]="['../','general']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!transactionForm.valid">Submit</button>
</div>
</form>
<mat-form-field>
<mat-label> Transaction date </mat-label>
<input matInput [min]="minDate" [matDatepicker]="transactionDatePicker" required formControlName="transactionDate">
<mat-datepicker-toggle matSuffix [for]="transactionDatePicker"></mat-datepicker-toggle>
<mat-datepicker #transactionDatePicker></mat-datepicker>
<mat-error *ngIf="transactionForm.controls.transactionDate.hasError('required')">
Transaction date <strong>is required</strong>
</mat-error>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="5px">
<button type="button" mat-raised-button [routerLink]="['../','general']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!transactionForm.valid">Submit</button>
</div>
</form>
</mat-card>
</div>
@@ -1,4 +1,3 @@
.tab-container {
padding: 1%;
margin: 1%;
.container {
max-width: 37rem;
}
@@ -1,9 +1,9 @@
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
<button mat-raised-button color="primary" [routerLink]="['../../','paycharge',chargeData.id]">
<button mat-raised-button color="primary" [routerLink]="['pay']" *mifosxHasPermission="'PAY_CLIENTCHARGE'">
<fa-icon icon="dollar-sign"></fa-icon>&nbsp;&nbsp;
Pay
</button>
<button mat-raised-button color="primary" (click)="waiveCharge()">
<button mat-raised-button color="primary" (click)="waiveCharge()" *mifosxHasPermission="'WAIVE_CLIENTCHARGE'">
<i class="fa fa-flag"></i>
Waive Charge
</button>
@@ -40,14 +40,14 @@ export class AcceptClientTransferComponent implements OnInit {
}
/**
* Creates the accept-approval savings form.
* Creates the accept client transfer form.
*/
ngOnInit() {
this.createAcceptClientTransferForm();
}
/**
* Creates the accept-approval savings account form.
* Creates the accept client transfer form.
*/
createAcceptClientTransferForm() {
this.acceptClientTransferForm = this.formBuilder.group({
@@ -23,7 +23,7 @@ export class ActivateClientComponent implements OnInit {
maxDate = new Date();
/** Activate client form. */
activateClientForm: FormGroup;
/** Client Account Id */
/** Client Id */
clientId: any;
/**
@@ -18,7 +18,7 @@ export class ClientAssignStaffComponent implements OnInit {
/** Client Assign Staff form. */
clientAssignStaffForm: FormGroup;
/** Field Officer Data */
/** Staff Data */
staffData: any;
/** Client Data */
clientData: any;
@@ -21,7 +21,7 @@ export class CloseClientComponent implements OnInit {
minDate = new Date(2000, 0, 1);
/** Maximum date allowed. */
maxDate = new Date();
/** Close Share Account form. */
/** Close Client form. */
closeClientForm: FormGroup;
/** Client Data */
closureData: any;
@@ -16,7 +16,7 @@ import { ClientsService } from 'app/clients/clients.service';
})
export class RejectClientTransferComponent implements OnInit {
/** Reject Approval Savings Account form. */
/** Reject Client Transfer form. */
rejectClientTransferForm: FormGroup;
/** Client Id */
clientId: any;
@@ -39,15 +39,12 @@ export class RejectClientTransferComponent implements OnInit {
this.clientId = this.route.parent.snapshot.params['clientId'];
}
/**
* Creates the reject-approval savings form.
*/
ngOnInit() {
this.createRejectClientTransferForm();
}
/**
* Creates the reject-approval savings account form.
* Creates the reject client transfer form.
*/
createRejectClientTransferForm() {
this.rejectClientTransferForm = this.formBuilder.group({
@@ -1,10 +1,11 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
/** Custom Services */
import { ClientsService } from '../../../clients.service';
import { AuthenticationService } from '../../../../core/authentication/authentication.service';
/**
* Take Survey Component
*/
@@ -13,7 +14,7 @@ import { AuthenticationService } from '../../../../core/authentication/authentic
templateUrl: './take-survey.component.html',
styleUrls: ['./take-survey.component.scss']
})
export class TakeSurveyComponent implements OnInit {
export class TakeSurveyComponent {
/** List of all Survey Data */
allSurveyData: any;
@@ -38,7 +39,10 @@ export class TakeSurveyComponent implements OnInit {
/**
* Retrieves the survey data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
* @param {ActivatedRoute} route Activated Route
* @param {ClientsService} clientsService ClientsService
* @param {Router} router Router
* @param {AuthenticationService} authenticationService AuthenticationService
*/
constructor(private route: ActivatedRoute,
private clientsService: ClientsService,
@@ -48,15 +52,12 @@ export class TakeSurveyComponent implements OnInit {
this.allSurveyData = data.clientActionData;
this.clientId = this.route.parent.parent.snapshot.paramMap.get('clientId');
});
/** Retrieves User ID */
const savedCredentials = this.authenticationService.getCredentials();
this.userId = savedCredentials.userId;
}
ngOnInit() {
}
// TODO: document the function
onSurveyChange(resEvent: any) {
if (resEvent.value) {
this.surveyData = resEvent.value;
@@ -68,6 +69,7 @@ export class TakeSurveyComponent implements OnInit {
}
}
// TODO: document the function
groupBy(array: any, func: any) {
const groups = {};
array.forEach((ele: any) => {
@@ -80,6 +82,24 @@ export class TakeSurveyComponent implements OnInit {
});
}
/**
* Checks if there is any response or not from the user and enables the submit button accordingly
*/
isAnyResponse(): boolean {
if (this.surveyData) {
this.surveyData.questionDatas.forEach((element: any) => {
if (element.answer) {
return false;
}
});
}
return true;
}
/**
* Submits the user survey response.
*/
submit() {
this.formData = {
userId: 0,
@@ -109,24 +129,9 @@ export class TakeSurveyComponent implements OnInit {
this.formData.scorecardValues.push(tmp);
}
});
// Submits the user survey response
this.clientsService.createNewSurvey(this.surveyData.id, this.formData).subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
// Checks if there is any response or not from the user and enables the submit button accordingly
isAnyResponse(): boolean {
if (this.surveyData) {
this.surveyData.questionDatas.forEach((element: any) => {
if (element.answer) {
return false;
}
});
}
return true;
}
}
@@ -16,7 +16,7 @@ import { ClientsService } from 'app/clients/clients.service';
})
export class UndoClientTransferComponent implements OnInit {
/** Undo Approval Savings Account form. */
/** Undo Client Transfer form. */
undoClientTransferForm: FormGroup;
/** Client Id */
clientId: any;
@@ -40,14 +40,14 @@ export class UndoClientTransferComponent implements OnInit {
}
/**
* Creates the undo-approval savings form.
* Creates the undo client transfer form.
*/
ngOnInit() {
this.createUndoClientTransferForm();
}
/**
* Creates the undo-approval savings account form.
* Creates the undo client transfer form.
*/
createUndoClientTransferForm() {
this.undoClientTransferForm = this.formBuilder.group({
@@ -18,7 +18,7 @@ export class UpdateClientSavingsAccountComponent implements OnInit {
/** Client Update Savings Account form. */
clientSavingsAccountForm: FormGroup;
/** Savings Accounts Officer Data */
/** Savings Accounts Data */
savingsAccounts: any;
/** Client Data */
clientData: any;
@@ -39,9 +39,6 @@ export class UpdateClientSavingsAccountComponent implements OnInit {
});
}
/**
* Creates the client update savings account form.
*/
ngOnInit() {
this.savingsAccounts = this.clientData.savingAccountOptions;
this.createClientSavingsAccountForm();
@@ -10,13 +10,13 @@
[src]="(clientImage)?clientImage:'assets/images/user_placeholder.png'">
</div>
<div fxLayoutAlign="center center" class="m-b-5">
<button class="client-image-button" mat-raised-button (click)="doAction('Upload Image')" matTooltip="Upload Image">
<button class="client-image-button" mat-raised-button (click)="doAction('Upload Image')" matTooltip="Upload Image" *mifosxHasPermission="'CREATE_CLIENTIMAGE'">
<i class="fa fa-upload"></i>
</button>
<button class="client-image-button" mat-raised-button (click)="doAction('Capture Image')" matTooltip="Capture Image">
<button class="client-image-button" mat-raised-button (click)="doAction('Capture Image')" matTooltip="Capture Image" *mifosxHasPermission="'CREATE_CLIENTIMAGE'">
<i class="fa fa-camera"></i>
</button>
<button class="client-image-button" mat-raised-button (click)="doAction('Delete Image')" matTooltip="Delete Image">
<button class="client-image-button" mat-raised-button (click)="doAction('Delete Image')" matTooltip="Delete Image" *mifosxHasPermission="'DELETE_CLIENTIMAGE'">
<i class="fa fa-trash"></i>
</button>
<br>
@@ -54,7 +54,7 @@
<mat-card-actions class="client-actions">
<span>
<span *mifosxHasPermission="'UPDATE_CLIENT'">
<button mat-raised-button [routerLink]="['edit']">
<i class="fa fa-edit"></i>Edit</button>
</span>
@@ -65,8 +65,8 @@
<button mat-menu-item [routerLink]="['loans', 'create-loans-account']">New Loan Account</button>
<button mat-menu-item [routerLink]="['savingsaccounts', 'create-savings-account']">New Savings Account</button>
<button mat-menu-item *mifosxHasPermission="'CREATE_SHAREACCOUNT'" [routerLink]="['shares-accounts', 'create']">New Share Account</button>
<button mat-menu-item [routerLink]="['recurringdeposits', 'create-recurring-deposits-account']">New Recurring Deposit Account</button>
<button mat-menu-item [routerLink]="['fixed-deposits-accounts', 'create']">New Fixed Deposits Account</button>
<button mat-menu-item *mifosxHasPermission="'CREATE_RECURRINGDEPOSITACCOUNT'" [routerLink]="['recurringdeposits', 'create-recurring-deposits-account']">New Recurring Deposit Account</button>
<button mat-menu-item *mifosxHasPermission="'CREATE_FIXEDDEPOSITACCOUNT'" [routerLink]="['fixed-deposits-accounts', 'create']">New Fixed Deposits Account</button>
</mat-menu>
<button mat-raised-button [matMenuTriggerFor]="Actions">
@@ -77,7 +77,7 @@
<span *ngIf="clientViewData.status.value === 'Pending'"><button mat-menu-item (click)="doAction('Activate')">Activate</button></span>
<span *ngIf="clientViewData.status.value === 'Pending'"><button mat-menu-item (click)="doAction('Withdraw')">Withdraw</button></span>
<span *ngIf="clientViewData.status.value === 'Pending'"><button mat-menu-item (click)="doAction('Reject')">Reject</button></span>
<span *ngIf="clientViewData.status.value === 'Pending'"><button mat-menu-item (click)="doAction('Delete')">Delete</button></span>
<span *ngIf="clientViewData.status.value === 'Pending'"><button mat-menu-item *mifosxHasPermission="'DELETE_CLIENT'" (click)="doAction('Delete')">Delete</button></span>
<span *ngIf="clientViewData.status.value === 'Closed'"><button mat-menu-item (click)="doAction('Reactivate')">Reactivate</button></span>
<span *ngIf="clientViewData.status.value === 'Rejected'"><button mat-menu-item (click)="doAction('Undo Rejection')">Undo Rejection</button></span>
<span *ngIf="clientViewData.status.value === 'Transfer in progress'"><button mat-menu-item (click)="doAction('Undo Transfer')">Undo Transfer</button></span>
@@ -90,22 +90,23 @@
<i class="fa fa-user"></i>Assign Staff</button>
</span>
<span *ngIf="clientViewData.staffId">
<button mat-raised-button (click)="doAction('Unassign Staff')">
<button mat-raised-button *mifosxHasPermission="'UNASSIGNSTAFF_CLIENT'" (click)="doAction('Unassign Staff')">
<i class="fa fa-user"></i>Unassign Staff</button>
</span>
<button mat-raised-button [matMenuTriggerFor]="More">More</button>
<mat-menu #More="matMenu">
<button mat-menu-item (click)="doAction('Add Charge')"> Add Charge </button>
<button mat-menu-item (click)="doAction('Add Charge')" *mifosxHasPermission="'CREATE_CLIENTCHARGE'"> Add Charge </button>
<button mat-menu-item (click)="doAction('Survey')">Survey</button>
<button mat-menu-item (click)="doAction('Update Default Savings')"> Update Default Savings </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('Update Default Savings')" *mifosxHasPermission="'UPDATESAVINGSACCOUNT_CLIENT'"> Update Default Savings </button>
<button mat-menu-item (click)="doAction('Upload Signature')" *mifosxHasPermission="'CREATE_CLIENTIMAGE'"> Upload Signature </button>
<button mat-menu-item (click)="doAction('Delete Signature')" *mifosxHasPermission="'DELETE_CLIENTIMAGE'"> Delete Signature </button>
<button mat-menu-item (click)="doAction('Client Screen Reports')"> Client Screen Reports </button>
<button mat-menu-item (click)="doAction('Create Standing Instructions')" *mifosxHasPermission="'READ_STANDINGINSTRUCTION'">Create Standing Instructions</button>
<span *ngIf="clientViewData.status.value!='Transfer on hold'">
<button mat-menu-item (click)="doAction('View Standing Instructions')" *mifosxHasPermission="'CREATE_STANDINGINSTRUCTION'">View Standing Instructions</button>
</span>
<!-- TODO: Create Self Service User -->
</mat-menu>
</mat-card-actions>
@@ -127,20 +128,23 @@
Family Members
</a>
<a mat-tab-link [routerLink]="['./identities']" routerLinkActive #identities="routerLinkActive"
[active]="identities.isActive">
[active]="identities.isActive" *mifosxHasPermission="'READ_CLIENTIDENTIFIER'">
Identities
</a>
<a mat-tab-link [routerLink]="['./documents']" routerLinkActive #documents="routerLinkActive"
[active]="documents.isActive">
[active]="documents.isActive" *mifosxHasPermission="'READ_DOCUMENT'">
Documents
</a>
<a mat-tab-link [routerLink]="['./notes']" routerLinkActive #notes="routerLinkActive" [active]="notes.isActive">
<a mat-tab-link [routerLink]="['./notes']" routerLinkActive #notes="routerLinkActive"
[active]="notes.isActive" *mifosxHasPermission="'READ_CLIENTNOTE'">
Notes
</a>
<a mat-tab-link *ngFor="let clientDatatable of clientDatatables" [routerLink]="['./datatables',clientDatatable.registeredTableName]"
routerLinkActive #datatable="routerLinkActive" [active]="datatable.isActive">
{{clientDatatable.registeredTableName}}
</a>
<ng-container *ngFor="let clientDatatable of clientDatatables">
<a mat-tab-link [routerLink]="['./datatables',clientDatatable.registeredTableName]"
routerLinkActive #datatable="routerLinkActive" [active]="datatable.isActive" *mifosxHasPermission="'READ_' + clientDatatable.registeredTableName">
{{clientDatatable.registeredTableName}}
</a>
</ng-container>
</nav>
<router-outlet></router-outlet>
@@ -4,9 +4,11 @@
<video #video width="540" height="480" autoplay></video>
<canvas #canvas class="canvas"></canvas>
<!-- Using a class will break renderer changes -->
<canvas #canvas [ngStyle]="{'display': 'none'}"></canvas>
<p #fallback class="fallback" align="center"></p>
<!-- Using a class will break renderer changes -->
<p #fallback [ngStyle]="{'display': 'none'}" align="center"></p>
<div fxFlex="20%" align="center">
<button #captureButton *ngIf="!isCaptured" mat-stroked-button color="primary" (click)="capture()">
@@ -1,7 +0,0 @@
.fallback {
display: none;
}
.canvas {
display: none;
}
@@ -4,7 +4,7 @@
<h3>Documents</h3>
<button mat-raised-button class="f-right" color="primary" (click)="uploadDocument()">
<button mat-raised-button class="f-right" color="primary" (click)="uploadDocument()" *mifosxHasPermission="'CREATE_DOCUMENT'">
<fa-icon icon="plus"></fa-icon>
&nbsp;&nbsp; Add
</button>
@@ -98,6 +98,7 @@
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutGap="32px" fxLayoutAlign="center">
<button type="button" mat-raised-button [routerLink]="['../']">Cancel</button>
<button type="submit" mat-raised-button color="primary" [disabled]="!addFamilyMemberForm.valid">Submit</button>
@@ -1,3 +1,4 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
@@ -6,13 +7,16 @@ import { DatePipe } from '@angular/common';
/** Custom Services */
import { ClientsService } from '../../../clients.service';
/**
* Add Family Member Component
*/
@Component({
selector: 'mifosx-add-family-member',
templateUrl: './add-family-member.component.html',
styleUrls: ['./add-family-member.component.scss']
})
export class AddFamilyMemberComponent implements OnInit {
/** Minimum Due Date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum Due Date allowed. */
@@ -21,12 +25,21 @@ export class AddFamilyMemberComponent implements OnInit {
addFamilyMemberForm: FormGroup;
/** Add family member template. */
addFamilyMemberTemplate: any;
/** Client ID */
clientId: any;
/**
* @param {FormBuilder} formBuilder FormBuilder
* @param {DatePipe} datePipe Date Pipe
* @param {Router} router Router
* @param {Route} route Route
* @param {ClientsService} clientsService Clients Service
*/
constructor(private formBuilder: FormBuilder,
private datePipe: DatePipe,
private router: Router,
private route: ActivatedRoute,
private clientsService: ClientsService) {
private datePipe: DatePipe,
private router: Router,
private route: ActivatedRoute,
private clientsService: ClientsService) {
this.route.data.subscribe((data: { clientTemplate: any }) => {
this.addFamilyMemberTemplate = data.clientTemplate.familyMemberOptions;
});
@@ -36,10 +49,11 @@ export class AddFamilyMemberComponent implements OnInit {
ngOnInit() {
this.createAddFamilyMemberForm();
}
/**
* Creates the add family member form
*/
createAddFamilyMemberForm() {
this.addFamilyMemberForm = this.formBuilder.group({
'firstName': ['', Validators.required],
@@ -56,6 +70,9 @@ export class AddFamilyMemberComponent implements OnInit {
});
}
/**
* Submits the form and adds the family member
*/
submit() {
const prevDateOfBirth: Date = this.addFamilyMemberForm.value.dateOfBirth;
// TODO: Update once language and date settings are setup
@@ -69,7 +86,6 @@ export class AddFamilyMemberComponent implements OnInit {
this.clientsService.addFamilyMember(this.clientId, familyMemberData).subscribe(res => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
}
@@ -98,6 +98,7 @@
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutGap="32px" fxLayoutAlign="center">
<button type="button" mat-raised-button [routerLink]="['../../']">Cancel</button>
<button type="submit" mat-raised-button color="primary" [disabled]="editFamilyMemberForm.pristine||!editFamilyMemberForm.valid">Submit</button>
@@ -1,3 +1,4 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
@@ -6,12 +7,16 @@ import { DatePipe } from '@angular/common';
/** Custom Services */
import { ClientsService } from '../../../clients.service';
/**
* Edit Family Member Component
*/
@Component({
selector: 'mifosx-edit-family-member',
templateUrl: './edit-family-member.component.html',
styleUrls: ['./edit-family-member.component.scss']
})
export class EditFamilyMemberComponent implements OnInit {
/** Minimum Due Date allowed. */
minDate = new Date(2000, 0, 1);
/** Maximum Due Date allowed. */
@@ -20,13 +25,21 @@ export class EditFamilyMemberComponent implements OnInit {
editFamilyMemberForm: FormGroup;
/** Add family member template. */
addFamilyMemberTemplate: any;
/** Family Members Details */
familyMemberDetails: any;
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {DatePipe} datePipe DatePipe
* @param {Router} router Router
* @param {ActivatedRoute} route Route
* @param {ClientsService} clientsService Clients Service
*/
constructor(private formBuilder: FormBuilder,
private datePipe: DatePipe,
private router: Router,
private route: ActivatedRoute,
private clientsService: ClientsService) {
private datePipe: DatePipe,
private router: Router,
private route: ActivatedRoute,
private clientsService: ClientsService) {
this.route.data.subscribe((data: { clientTemplate: any, editFamilyMember: any }) => {
this.addFamilyMemberTemplate = data.clientTemplate.familyMemberOptions;
this.familyMemberDetails = data.editFamilyMember;
@@ -35,9 +48,12 @@ export class EditFamilyMemberComponent implements OnInit {
ngOnInit() {
this.createEditFamilyMemberForm(this.familyMemberDetails);
}
/**
* Creates Edit Family Member Form
* @param {any} familyMember Family Member
*/
createEditFamilyMemberForm(familyMember: any) {
this.editFamilyMemberForm = this.formBuilder.group({
'firstName': [familyMember.firstName, Validators.required],
@@ -54,6 +70,9 @@ export class EditFamilyMemberComponent implements OnInit {
});
}
/**
* Submits the form and updates the client family member.
*/
submit() {
const prevDateOfBirth: Date = this.editFamilyMemberForm.value.dateOfBirth;
// TODO: Update once language and date settings are setup
@@ -67,6 +86,6 @@ export class EditFamilyMemberComponent implements OnInit {
this.clientsService.editFamilyMember(this.familyMemberDetails.clientId, this.familyMemberDetails.id, familyMemberData).subscribe(res => {
this.router.navigate(['../../'], { relativeTo: this.route });
});
}
}
@@ -1,13 +1,19 @@
<div class="tab-container mat-typography">
<router-outlet>
<h3>Family Members</h3>
<div fxLayout="row" fxLayoutAlign="flex-end">
<button mat-raised-button color="primary" [routerLink]="['./add']">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp;Add
</button>
</div>
<mat-accordion>
<mat-expansion-panel *ngFor="let member of clientFamilyMembers;index as i" class="family-member">
<mat-expansion-panel-header>
<mat-panel-title>
{{member.firstName+' '+member.middleName+' '+member.lastName}}
@@ -16,7 +22,9 @@
{{member.relationship}}
</mat-panel-description>
</mat-expansion-panel-header>
<mat-divider [inset]="true"></mat-divider>
<div class="family-member-actions" fxLayout="row" fxLayoutAlign="flex-end">
<button mat-button color="primary">
<fa-icon icon="edit" [routerLink]="[member.id,'edit']"></fa-icon>
@@ -24,8 +32,8 @@
<button mat-button color="warn" (click)="deleteFamilyMember(member.clientId,member.id,member.firstName,i)">
<fa-icon icon="trash"></fa-icon>
</button>
</div>
<p>
First Name : {{member.firstName}}<br />
Middle Name : {{member.middleName}}<br />
@@ -43,5 +51,7 @@
</mat-expansion-panel>
</mat-accordion>
</router-outlet>
</div>
</div>
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
/** Angular Imports */
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MatDialog } from '@angular/material';
/** Custom Components */
@@ -8,25 +9,32 @@ import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dial
/** Custom Services */
import { ClientsService } from '../../clients.service';
/**
* Client Family Members Tab
*/
@Component({
selector: 'mifosx-family-members-tab',
templateUrl: './family-members-tab.component.html',
styleUrls: ['./family-members-tab.component.scss']
})
export class FamilyMembersTabComponent implements OnInit {
export class FamilyMembersTabComponent {
/** Client Family Members */
clientFamilyMembers: any;
/**
* @param {ActivatedRoute} route Activated Route
* @param {ClientsService} clientsService Clients Service
* @param {MatDialog }dialog Mat Dialog
*/
constructor(private route: ActivatedRoute,
private router: Router,
private clientsService: ClientsService,
public dialog: MatDialog) {
private clientsService: ClientsService,
public dialog: MatDialog) {
this.route.data.subscribe((data: { clientFamilyMembers: any }) => {
this.clientFamilyMembers = data.clientFamilyMembers;
});
}
ngOnInit() {
}
/**
* Deletes the family member and redirects to family members tab.
*/
@@ -1,4 +1,5 @@
<div class="tab-container mat-typography">
<h3>Performance History</h3>
<div fxLayout="row" fxLayoutGap="32px" class="performance-history-container">
<p>
@@ -13,26 +14,26 @@
</div>
<!-- Upcoming Charges -->
<div class="headingContent">
<div class="heading-content">
<div fxLayout="column" fxFlex="50%">
<div className="headingName">
<div className="heading-name">
<h3>Upcoming Charges</h3>
</div>
</div>
<div fxLayout="column" fxFlex="50%">
<div fxLayout="row" fxLayoutAlign="flex-end">
<button mat-raised-button class="f-right" color="primary" [routerLink]="['../', 'charges', 'overview']">Charges
<button mat-raised-button class="f-right" color="primary" [routerLink]="['../', 'charges', 'overview']" *mifosxHasPermission="'READ_CLIENTCHARGE'">Charges
Overview</button>
</div>
</div>
</div>
<table mat-table [dataSource]="upcomingCharges">
<ng-container matColumnDef="Name">
<th mat-header-cell *matHeaderCellDef> Name </th>
<td mat-cell *matCellDef="let element"> <i class="fa fa-stop"
[ngClass]="(!(element.isWaived || element.isPaid))|statusLookup"></i>
[ngClass]="(!(element.isWaived || element.isPaid)) | statusLookup"></i>
{{element.name}} </td>
</ng-container>
@@ -45,6 +46,7 @@
<th mat-header-cell *matHeaderCellDef> Due </th>
<td mat-cell *matCellDef="let element"> {{element.amount}} </td>
</ng-container>
<ng-container matColumnDef="Paid">
<th mat-header-cell *matHeaderCellDef>Paid </th>
<td mat-cell *matCellDef="let element"> {{element.amountPaid}} </td>
@@ -55,22 +57,20 @@
<td mat-cell *matCellDef="let element"> {{element.amountWaived}} </td>
</ng-container>
<ng-container matColumnDef="Outstanding">
<th mat-header-cell *matHeaderCellDef> Outstanding </th>
<td mat-cell *matCellDef="let element"> {{element.amountOutstanding}} </td>
</ng-container>
<ng-container matColumnDef="Actions">
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let element">
<button class="account-action-button" mat-raised-button color="primary"
(click)="routeEdit($event)" [routerLink]="['../','charges', element.id, 'pay']">
(click)="routeEdit($event)" [routerLink]="['../','charges', element.id, 'pay']" *mifosxHasPermission="'PAY_CLIENTCHARGE'">
<i class="fa fa-dollar"></i>
</button>
<button class="account-action-button" mat-raised-button color="primary"
(click)="routeEdit($event); waiveCharge(element.id,element.clientId)">
(click)="routeEdit($event); waiveCharge(element.id,element.clientId)" *mifosxHasPermission="'WAIVE_CLIENTCHARGE'">
<i class="fa fa-flag"></i>
</button>
</td>
@@ -79,13 +79,13 @@
<tr mat-header-row *matHeaderRowDef="upcomingChargesColumns"></tr>
<tr mat-row *matRowDef="let row; columns: upcomingChargesColumns;" [routerLink]="['../','charges',row.id]"></tr>
</table>
<!-- loans overview table -->
<div class="headingContent">
<div class="heading-content">
<div fxLayout="column" fxFlex="50%">
<div class="headingName">
<div class="heading-name">
<h3>Loan Accounts</h3>
</div>
</div>
@@ -96,6 +96,7 @@
</div>
</div>
</div>
<table *ngIf="!showClosedLoanAccounts" mat-table [dataSource]="loanAccounts|accountsFilter:'loan'">
<ng-container matColumnDef="Account No">
@@ -125,7 +126,6 @@
<td mat-cell *matCellDef="let element"> {{element.accountBalance}} </td>
</ng-container>
<ng-container matColumnDef="Type">
<th mat-header-cell *matHeaderCellDef> Type </th>
<td mat-cell *matCellDef="let element">
@@ -133,7 +133,6 @@
</td>
</ng-container>
<ng-container matColumnDef="Actions">
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let element">
@@ -168,6 +167,7 @@
<tr mat-header-row *matHeaderRowDef="openLoansColumns"></tr>
<tr mat-row *matRowDef="let row; columns: openLoansColumns;"
[routerLink]="['../', 'loans', row.id, 'general']" class="select-row"></tr>
</table>
<!-- Closed Loan Accounts -->
@@ -190,6 +190,7 @@
<th mat-header-cell *matHeaderCellDef> Original Loan </th>
<td mat-cell *matCellDef="let element"> {{element.lastActiveTransactionDate | date}} </td>
</ng-container>
<ng-container matColumnDef="Loan Balance">
<th mat-header-cell *matHeaderCellDef>Loan Balance </th>
<td mat-cell *matCellDef="let element"> {{element.loanBalance}} </td>
@@ -200,7 +201,6 @@
<td mat-cell *matCellDef="let element"> {{element.accountBalance}} </td>
</ng-container>
<ng-container matColumnDef="Type">
<th mat-header-cell *matHeaderCellDef> Type </th>
<td mat-cell *matCellDef="let element">
@@ -216,13 +216,13 @@
<tr mat-header-row *matHeaderRowDef="closedLoansColumns"></tr>
<tr mat-row *matRowDef="let row; columns: closedLoansColumns;"
[routerLink]="['../', 'loans', row.id, 'general']" class="select-row"></tr>
</table>
<!-- Saving overview Table -->
<div class="headingContent">
<div class="heading-content">
<div fxLayout="column" fxFlex="50%">
<div class="headingName">
<div class="heading-name">
<h3>Saving Accounts</h3>
</div>
</div>
@@ -289,6 +289,7 @@
<tr mat-header-row *matHeaderRowDef="openSavingsColumns"></tr>
<tr mat-row *matRowDef="let row; columns: openSavingsColumns;"
[routerLink]="['../', 'savingsaccounts', row.id, 'transactions']"></tr>
</table>
<!-- Closed Saving Accounts -->
@@ -314,13 +315,13 @@
<tr mat-header-row *matHeaderRowDef="closedSavingsColumns"></tr>
<tr mat-row *matRowDef="let row; columns: closedSavingsColumns;"></tr>
</table>
<!-- Fixed Deposit Table -->
<div class="headingContent">
<div class="heading-content">
<div fxLayout="column" fxFlex="50%">
<div class="headingName">
<div class="heading-name">
<h3>Fixed Deposit Accounts</h3>
</div>
</div>
@@ -331,6 +332,7 @@
</div>
</div>
</div>
<table *ngIf="!showClosedFixedAccounts" mat-table
[dataSource]="savingAccounts|accountsFilter:'saving':'open':'isFixed'">
@@ -378,6 +380,7 @@
<tr mat-header-row *matHeaderRowDef="openSavingsColumns"></tr>
<tr mat-row *matRowDef="let row; columns: openSavingsColumns;"
[routerLink]="['../', 'fixed-deposits-accounts', row.id, 'interest-rate-chart']"></tr>
</table>
<!-- Closed Fixed Deposit Accounts -->
@@ -404,12 +407,13 @@
<tr mat-header-row *matHeaderRowDef="closedSavingsColumns"></tr>
<tr mat-row *matRowDef="let row; columns: closedSavingsColumns;"
[routerLink]="['../', 'fixed-deposits-account', row.id]"></tr>
</table>
<!-- Recurring Deposit Table -->
<div class="headingContent">
<div class="heading-content">
<div fxLayout="column" fxFlex="50%">
<div class="headingName">
<div class="heading-name">
<h3>Recurring Deposit Accounts</h3>
</div>
</div>
@@ -468,16 +472,15 @@
</button>
</ng-container>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="openSavingsColumns"></tr>
<tr mat-row *matRowDef="let row; columns: openSavingsColumns;"
[routerLink]="['../', 'recurringdeposits', row.id, 'interest-rate-chart']" class="select-row"></tr>
</table>
<!-- Closed Recurring Deposit Accounts -->
<table *ngIf="showClosedRecurringAccounts" mat-table
[dataSource]="savingAccounts|accountsFilter:'saving':'closed':'isRecurring'">
@@ -503,9 +506,9 @@
</table>
<!-- Shares overview Table -->
<div class="headingContent">
<div class="heading-content">
<div fxLayout="column" fxFlex="50%">
<div class="headingName">
<div class="heading-name">
<h3>Shares Accounts</h3>
</div>
</div>
@@ -556,13 +559,14 @@
<i class="fa fa-check-circle"></i>
</button>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="openSharesColumns"></tr>
<tr mat-row *matRowDef="let row; columns: openSharesColumns;"
[routerLink]="['../', 'shares-accounts', row.id, 'transactions']"></tr>
</table>
<!-- Closed Share Accounts -->
<table *ngIf="showClosedShareAccounts" mat-table [dataSource]="shareAccounts|accountsFilter:'share':'closed'">
@@ -594,6 +598,7 @@
<tr mat-header-row *matHeaderRowDef="closedSharesColumns"></tr>
<tr mat-row *matRowDef="let row; columns: closedSharesColumns;"></tr>
</table>
</div>
@@ -29,11 +29,11 @@
}
.headingContent{
.heading-content {
margin-bottom: 1%;
margin-top: 1%;
}
.headingName {
.heading-name {
display: block;
}
@@ -1,7 +1,6 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { DatePipe } from '@angular/common';
/** Custom Services. */
import { ClientsService } from 'app/clients/clients.service';
@@ -15,27 +14,54 @@ import { ClientsService } from 'app/clients/clients.service';
styleUrls: ['./general-tab.component.scss']
})
export class GeneralTabComponent {
/** Open Loan Accounts Columns */
openLoansColumns: string[] = ['Account No', 'Loan Account', 'Original Loan', 'Loan Balance', 'Amount Paid', 'Type', 'Actions'];
/** Closed Loan Accounts Columns */
closedLoansColumns: string[] = ['Account No', 'Loan Account', 'Original Loan', 'Loan Balance', 'Amount Paid', 'Type', 'Closed Date'];
/** Open Savings Accounts Columns */
openSavingsColumns: string[] = ['Account No', 'Saving Account', 'Last Active', 'Balance', 'Actions'];
/** Closed Savings Accounts Columns */
closedSavingsColumns: string[] = ['Account No', 'Saving Account', 'Closed Date'];
/** Open Shares Accounts Columns */
openSharesColumns: string[] = ['Account No', 'Share Account', 'Approved Shares', 'Pending For Approval Shares', 'Actions'];
/** Closed Shares Accounts Columns */
closedSharesColumns: string[] = ['Account No', 'Share Account', 'Approved Shares', 'Pending For Approval Shares', 'Closed Date'];
/** Upcoming Charges Columns */
upcomingChargesColumns: string[] = ['Name', 'Due as of', 'Due', 'Paid', 'Waived', 'Outstanding', 'Actions'];
/** Client Account Data */
clientAccountData: any;
/** Loan Accounts Data */
loanAccounts: any;
/** Savings Accounts Data */
savingAccounts: any;
/** Shares Accounts Data */
shareAccounts: any;
/** Upcoming Charges Data */
upcomingCharges: any;
/** Client Summary Data */
clientSummary: any;
/** Show Closed Loan Accounts */
showClosedLoanAccounts = false;
/** Show Closed Saving Accounts */
showClosedSavingAccounts = false;
/** Show Closed Share Accounts */
showClosedShareAccounts = false;
/** Show Closed Reccuring Deposits Accounts */
showClosedRecurringAccounts = false;
/** Show Closed Fixed Deposits Accounts */
showClosedFixedAccounts = false;
/** Client Id */
clientid: any;
/**
* @param {ActivatedRoute} route Activated Route
* @param {ClientsService} clientService Clients Service
* @param {Router} router Router
*/
constructor(
private route: ActivatedRoute,
private clientService: ClientsService,
@@ -52,21 +78,37 @@ export class GeneralTabComponent {
});
}
/**
* Toggles Loan Accounts Overview
*/
toggleLoanAccountsOverview() {
this.showClosedLoanAccounts = !this.showClosedLoanAccounts;
}
/**
* Toggles Loan Accounts Overview
*/
toggleSavingAccountsOverview() {
this.showClosedSavingAccounts = !this.showClosedSavingAccounts;
}
/**
* Toggles Loan Accounts Overview
*/
toggleShareAccountsOverview() {
this.showClosedShareAccounts = !this.showClosedShareAccounts;
}
/**
* Toggles Reccuring Accounts Overview
*/
toggleRecurringAccountsOverview() {
this.showClosedRecurringAccounts = !this.showClosedRecurringAccounts;
}
/**
* Toggles Fixed Accounts Overview
*/
toggleFixedAccountsOverview() {
this.showClosedFixedAccounts = !this.showClosedFixedAccounts;
}
@@ -93,7 +135,6 @@ export class GeneralTabComponent {
});
}
/**
* Stops the propagation to view pages.
* @param $event Mouse Event
@@ -102,6 +143,9 @@ export class GeneralTabComponent {
$event.stopPropagation();
}
/**
* @param {any} loanId Loan Id
*/
routeTransferFund(loanId: any) {
const queryParams: any = { loanId: loanId, accountType: 'fromloans' };
this.router.navigate(['../', 'loans', loanId, 'transfer-funds', 'make-account-transfer'], { relativeTo: this.route, queryParams: queryParams });
@@ -1,62 +1,60 @@
<div class="tab-container mat-typography">
<!-- Identities Table -->
<h3>Identities</h3>
<button mat-raised-button class="f-right" color="primary" (click)="addIdentifier()">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp; Add
</button>
<button mat-raised-button class="f-right" color="primary" (click)="addIdentifier()" *mifosxHasPermission="'CREATE_CLIENTIDENTIFIER'">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp; Add
</button>
<table mat-table #identifiersTable [dataSource]="clientIdentities">
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef> Id </th>
<td mat-cell *matCellDef="let identity">
{{identity.id}} </td>
<th mat-header-cell *matHeaderCellDef> Id </th>
<td mat-cell *matCellDef="let identity">{{identity.id}}</td>
</ng-container>
<ng-container matColumnDef="description">
<th mat-header-cell *matHeaderCellDef> Description </th>
<td mat-cell *matCellDef="let identity"> {{identity.description}} </td>
<th mat-header-cell *matHeaderCellDef> Description </th>
<td mat-cell *matCellDef="let identity"> {{identity.description}} </td>
</ng-container>
<ng-container matColumnDef="type">
<th mat-header-cell *matHeaderCellDef> type </th>
<td mat-cell *matCellDef="let identity"> {{identity.documentType.name}}
</td>
<th mat-header-cell *matHeaderCellDef> type </th>
<td mat-cell *matCellDef="let identity"> {{identity.documentType.name}}</td>
</ng-container>
<ng-container matColumnDef="documents">
<th mat-header-cell *matHeaderCellDef>Identity Documents </th>
<td mat-cell *matCellDef="let identity">
<div *ngFor="let document of identity.documents">
{{document.name}}
<fa-icon icon="cloud-download-alt" (click)="download(document.parentEntityId,document.id)"></fa-icon>
</div>
</td>
<th mat-header-cell *matHeaderCellDef>Identity Documents </th>
<td mat-cell *matCellDef="let identity">
<div *ngFor="let document of identity.documents">
{{document.name}}
<fa-icon icon="cloud-download-alt" (click)="download(document.parentEntityId,document.id)" *mifosxHasPermission="'READ_DOCUMENT'"></fa-icon>
</div>
</td>
</ng-container>
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef> Status </th>
<td mat-cell *matCellDef="let identity">
{{(identity.status==='clientIdentifierStatusType.active')?'active':'inactive'}} </td>
<th mat-header-cell *matHeaderCellDef> Status </th>
<td mat-cell *matCellDef="let identity">
{{(identity.status==='clientIdentifierStatusType.active')?'active':'inactive'}}
</td>
</ng-container>
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let identity; let i = index">
<button class="identity-action-button" mat-raised-button color="primary" (click)="uploadDocument(i,identity.id)">
<fa-icon icon="cloud-upload-alt"></fa-icon>
</button>
<button class="identity-action-button" mat-raised-button color="warn" (click)="deleteIdentifier(identity.clientId,identity.id,i)">
<fa-icon icon="times"></fa-icon>
</button>
</td>
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let identity; let i = index">
<button class="identity-action-button" mat-raised-button color="primary" (click)="uploadDocument(i,identity.id)" *mifosxHasPermission="'CREATE_DOCUMENT'">
<fa-icon icon="cloud-upload-alt"></fa-icon>
</button>
<button class="identity-action-button" mat-raised-button color="warn" (click)="deleteIdentifier(identity.clientId,identity.id,i)" *mifosxHasPermission="'DELETE_CLIENTIDENTIFIER'">
<fa-icon icon="times"></fa-icon>
</button>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="identitiesColumns"></tr>
<tr mat-row *matRowDef="let row; columns: identitiesColumns;"></tr>
</table>
</div>
@@ -1,7 +1,10 @@
import { Component, OnInit, ViewChild } from '@angular/core';
/** Angular Imports */
import { Component, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MatTable } from '@angular/material/table';
import { MatDialog } from '@angular/material';
/** Custom Models */
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
@@ -14,22 +17,36 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen
/** Custom Services */
import { ClientsService } from '../../clients.service';
/**
* Identities Tab Component
*/
@Component({
selector: 'mifosx-identities-tab',
templateUrl: './identities-tab.component.html',
styleUrls: ['./identities-tab.component.scss']
})
export class IdentitiesTabComponent implements OnInit {
export class IdentitiesTabComponent {
@ViewChild('identifiersTable') identifiersTable: MatTable<Element>;
identitiesColumns: string[] = ['id', 'description', 'type', 'documents', 'status', 'actions'];
/** Client Identities */
clientIdentities: any;
/** Client Identifier Template */
clientIdentifierTemplate: any;
/** Client Id */
clientId: string;
/** Identities Columns */
identitiesColumns: string[] = ['id', 'description', 'type', 'documents', 'status', 'actions'];
/** Identifiers Table */
@ViewChild('identifiersTable') identifiersTable: MatTable<Element>;
/**
* @param {ActivatedRoute} route Activated Route
* @param {MatDialog} dialog Mat Dialog
* @param {ClientsService} clientService Clients Service
*/
constructor(private route: ActivatedRoute,
public dialog: MatDialog,
private clientService: ClientsService) {
public dialog: MatDialog,
private clientService: ClientsService) {
this.clientId = this.route.parent.snapshot.paramMap.get('clientId');
this.route.data.subscribe((data: { clientIdentities: any, clientIdentifierTemplate: any }) => {
this.clientIdentities = data.clientIdentities;
@@ -37,8 +54,11 @@ export class IdentitiesTabComponent implements OnInit {
});
}
ngOnInit() { }
/**
* Download Client Document
* @param {string} parentEntityId Parent Entity Id
* @param {string} documentId Document ID
*/
download(parentEntityId: string, documentId: string) {
this.clientService.downloadClientIdentificationDocument(parentEntityId, documentId).subscribe(res => {
const url = window.URL.createObjectURL(res);
@@ -46,6 +66,9 @@ export class IdentitiesTabComponent implements OnInit {
});
}
/**
* Add Client Identifier
*/
addIdentifier() {
const formfields: FormfieldBase[] = [
new SelectBase({
@@ -103,6 +126,12 @@ export class IdentitiesTabComponent implements OnInit {
});
}
/**
* Delete Client Identifier
* @param {string} clientId Client Id
* @param {string} identifierId Identifier Id
* @param {number} index Index
*/
deleteIdentifier(clientId: string, identifierId: string, index: number) {
const deleteIdentifierDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `identifier id:${identifierId}` }
@@ -117,6 +146,11 @@ export class IdentitiesTabComponent implements OnInit {
});
}
/**
* Upload Document
* @param {number} index Index
* @param {string} identifierId Identifier Id
*/
uploadDocument(index: number, identifierId: string) {
const uploadDocumentDialogRef = this.dialog.open(UploadDocumentDialogComponent, {
data: { documentIdentifier: true }
@@ -1,17 +1,26 @@
<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">
<button mat-raised-button fxFlex color="primary" [disabled]="!noteForm.valid" *mifosxHasPermission="'CREATE_CLIENTNOTE'">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp; Add
</button>
</form>
</div>
<mat-list>
<mat-list-item *ngFor="let clientNote of clientNotes; let i=index;">
<fa-icon icon="sticky-note" matListIcon></fa-icon>
<h3 matLine>{{clientNote.note}} </h3>
@@ -20,13 +29,15 @@
<span>Date: {{clientNote.createdOn | date}}</span>
</p>
<div fxLayout="row" fxLayoutAlign="flex-start">
<button mat-button color="primary" (click)="editNote(clientNote.id,clientNote.note,i)">
<button mat-button color="primary" (click)="editNote(clientNote.id,clientNote.note,i)" *mifosxHasPermission="'CREATE_CLIENTNOTE'">
<fa-icon icon="edit"></fa-icon>
</button>
<button mat-button color="warn" (click)="deleteNote(clientNote.id,i)">
<button mat-button color="warn" (click)="deleteNote(clientNote.id,i)" *mifosxHasPermission="'DELETE_CLIENTNOTE'">
<fa-icon icon="trash"></fa-icon>
</button>
</div>
</mat-list-item>
</mat-list>
</div>
@@ -1,3 +1,4 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MatDialog } from '@angular/material';
@@ -10,24 +11,38 @@ import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dial
import { ClientsService } from '../../clients.service';
import { EditNotesDialogComponent } from '../custom-dialogs/edit-notes-dialog/edit-notes-dialog.component';
/**
* Notes Tab Component
*/
@Component({
selector: 'mifosx-notes-tab',
templateUrl: './notes-tab.component.html',
styleUrls: ['./notes-tab.component.scss']
})
export class NotesTabComponent implements OnInit {
/** Client ID */
clientId: string;
/** Username */
username: string;
/** Client Notes */
clientNotes: any;
/** Note Form */
noteForm: FormGroup;
/** Notes Form Reference */
@ViewChild('formRef') formRef: any;
/**
* @param {ActivatedRoute} route Activated Route
* @param {FormBuilder} formBuilder Form Builder
* @param {ClientsService} clientsService Clients Service
* @param {MatDialog} dialog Mat Dialog
*/
constructor(private route: ActivatedRoute,
private formBuilder: FormBuilder,
private clientsService: ClientsService,
public dialog: MatDialog) {
private formBuilder: FormBuilder,
private clientsService: ClientsService,
public dialog: MatDialog) {
this.username = JSON.parse(sessionStorage.getItem('mifosXCredentials')).username;
this.clientId = this.route.parent.snapshot.params['clientId'];
this.route.data.subscribe((data: { clientNotes: any }) => {
@@ -39,24 +54,21 @@ export class NotesTabComponent implements OnInit {
this.createNoteForm();
}
/**
* Creates the note form
*/
createNoteForm() {
this.noteForm = this.formBuilder.group({
'note': ['', Validators.required]
});
}
submit() {
this.clientsService.createClientNote(this.clientId, this.noteForm.value).subscribe((response: any) => {
this.clientNotes.push({
id: response.resourceId,
createdByUsername: this.username,
createdOn: new Date(),
note: this.noteForm.value.note
});
this.formRef.resetForm();
});
}
/**
* Edits a client note.
* @param {string} noteId Note Id
* @param {string} noteContent Note Content
* @param {number} index Index
*/
editNote(noteId: string, noteContent: string, index: number) {
const editNoteDialogRef = this.dialog.open(EditNotesDialogComponent, {
data: { noteContent: noteContent }
@@ -70,8 +82,11 @@ export class NotesTabComponent implements OnInit {
});
}
/**
* Deletes a client note.
* @param {string} noteId Note Id
* @param {number} index Index
*/
deleteNote(noteId: string, index: number) {
const deleteNoteDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `Note id:${noteId}` }
@@ -86,4 +101,19 @@ export class NotesTabComponent implements OnInit {
});
}
/**
* Creates a client note.
*/
submit() {
this.clientsService.createClientNote(this.clientId, this.noteForm.value).subscribe((response: any) => {
this.clientNotes.push({
id: response.resourceId,
createdByUsername: this.username,
createdOn: new Date(),
note: this.noteForm.value.note
});
this.formRef.resetForm();
});
}
}
+2 -2
View File
@@ -8,10 +8,10 @@
</mat-checkbox>
</div>
<div class="action-button" fxLayoutGap="25px">
<button mat-raised-button color="primary" [routerLink]="['../', 'organization', 'bulk-import', 'Clients']">
<button mat-raised-button color="primary" [routerLink]="['../', 'organization', 'bulk-import', 'Clients']" *mifosxHasPermission="'CREATE_CLIENT'">
<fa-icon icon="download"></fa-icon>&nbsp;&nbsp;Import Client
</button>
<button mat-raised-button color="primary" [routerLink]="['create']">
<button mat-raised-button color="primary" [routerLink]="['create']" *mifosxHasPermission="'CREATE_CLIENT'">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp;Create Client
</button>
</div>