@@ -0,0 +1,43 @@
|
|||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<mat-card>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<form #formRef="ngForm" [formGroup]="fundForm" fxLayout="row" fxLayoutAlign="start baseline" fxLayoutGap="20px"
|
||||||
|
(ngSubmit)="addFund()">
|
||||||
|
|
||||||
|
<mat-form-field fxFlex="calc(90%-20px)">
|
||||||
|
<textarea formControlName="name" matInput placeholder="New Fund"></textarea>
|
||||||
|
<mat-error *ngIf="fundForm.controls.name.hasError('required')">
|
||||||
|
<strong>Required field</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<button mat-raised-button fxFlex color="primary" [disabled]="!fundForm.valid">
|
||||||
|
<fa-icon icon="plus"></fa-icon>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<mat-grid-list cols="2" rowHeight="50px">
|
||||||
|
|
||||||
|
<mat-grid-tile *ngFor="let fund of fundsData; index as i">
|
||||||
|
|
||||||
|
<input matInput [value]="fund.name">
|
||||||
|
|
||||||
|
<div fxLayout="row" fxLayoutAlign="flex-start">
|
||||||
|
<button mat-button color="primary" (click)="editFund(fund.id,fund.name,i)">
|
||||||
|
<fa-icon icon="edit"></fa-icon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</mat-grid-tile>
|
||||||
|
|
||||||
|
</mat-grid-list>
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.container{
|
||||||
|
width: 74rem;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ManageFundsComponent } from './manage-funds.component';
|
||||||
|
|
||||||
|
describe('ManageFundsComponent', () => {
|
||||||
|
let component: ManageFundsComponent;
|
||||||
|
let fixture: ComponentFixture<ManageFundsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ManageFundsComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ManageFundsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
/** Angular Imports */
|
||||||
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { MatDialog } from '@angular/material';
|
||||||
|
import { FormBuilder, Validators } from '@angular/forms';
|
||||||
|
|
||||||
|
/** Custom Dialogs */
|
||||||
|
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
|
||||||
|
|
||||||
|
/** Custom Models */
|
||||||
|
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
|
||||||
|
import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
|
||||||
|
|
||||||
|
/** Custom Services */
|
||||||
|
import { OrganizationService } from '../organization.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manage Funds component.
|
||||||
|
*/
|
||||||
|
@Component({
|
||||||
|
selector: 'mifosx-manage-funds',
|
||||||
|
templateUrl: './manage-funds.component.html',
|
||||||
|
styleUrls: ['./manage-funds.component.scss']
|
||||||
|
})
|
||||||
|
export class ManageFundsComponent implements OnInit {
|
||||||
|
|
||||||
|
/** Manage Funds data. */
|
||||||
|
fundsData: any;
|
||||||
|
/** New Fund form */
|
||||||
|
fundForm: any;
|
||||||
|
/** Funds form reference */
|
||||||
|
@ViewChild('formRef') formRef: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the manage funds data from `resolve`.
|
||||||
|
* @param {ActivatedRoute} route Activated Route
|
||||||
|
* @param {FormBuilder} formBuilder Form Builder
|
||||||
|
* @param {OrganizationService} organizationservice Organization Service
|
||||||
|
* @param {MatDialog} dialog Mat Dialog
|
||||||
|
*/
|
||||||
|
constructor(private route: ActivatedRoute,
|
||||||
|
private formBuilder: FormBuilder,
|
||||||
|
private organizationservice: OrganizationService,
|
||||||
|
public dialog: MatDialog) {
|
||||||
|
this.route.data.subscribe(( data: { funds: any }) => {
|
||||||
|
this.fundsData = data.funds;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.createFundForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the fund form.
|
||||||
|
*/
|
||||||
|
createFundForm() {
|
||||||
|
this.fundForm = this.formBuilder.group({
|
||||||
|
'name': ['', Validators.required]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new fund to the list.
|
||||||
|
*/
|
||||||
|
addFund() {
|
||||||
|
const newFund = this.fundForm.value;
|
||||||
|
this.organizationservice.createFund(newFund).subscribe((response: any) => {
|
||||||
|
this.fundsData.push({
|
||||||
|
id: response.resourceId,
|
||||||
|
name: newFund.name
|
||||||
|
});
|
||||||
|
this.formRef.resetForm();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edits the selected fund.
|
||||||
|
* @param {string} fundId Fund Id.
|
||||||
|
* @param {string} fundContent Fund's content.
|
||||||
|
* @param {number} index Index of fund.
|
||||||
|
*/
|
||||||
|
editFund(fundId: string, fundContent: string, index: number) {
|
||||||
|
const formfields: FormfieldBase[] = [
|
||||||
|
new InputBase({
|
||||||
|
controlName: 'name',
|
||||||
|
label: 'Fund Content',
|
||||||
|
value: fundContent,
|
||||||
|
type: 'text',
|
||||||
|
required: true
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
const data = {
|
||||||
|
title: 'Edit Fund',
|
||||||
|
layout: { addButtonText: 'Confirm' },
|
||||||
|
formfields: formfields
|
||||||
|
};
|
||||||
|
const editFundDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||||
|
editFundDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
|
if (response.data) {
|
||||||
|
this.organizationservice.editFund(fundId, response.data.value).subscribe(() => {
|
||||||
|
this.fundsData[index].name = response.data.value.name;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/** Angular Imports */
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Resolve } from '@angular/router';
|
||||||
|
|
||||||
|
/** rxjs Imports */
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
/** Custom Services */
|
||||||
|
import { OrganizationService } from '../organization.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manage Funds data resolver.
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
export class ManageFundsResolver implements Resolve<Object> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {OrganizationService} organizationService Organization service.
|
||||||
|
*/
|
||||||
|
constructor(private organizationService: OrganizationService) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the manage funds data.
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
resolve(): Observable<any> {
|
||||||
|
return this.organizationService.getFunds();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -39,6 +39,7 @@ import { ViewOfficeComponent } from './offices/view-office/view-office.component
|
|||||||
import { GeneralTabComponent } from './offices/view-office/general-tab/general-tab.component';
|
import { GeneralTabComponent } from './offices/view-office/general-tab/general-tab.component';
|
||||||
import { DatatableTabsComponent } from './offices/view-office/datatable-tabs/datatable-tabs.component';
|
import { DatatableTabsComponent } from './offices/view-office/datatable-tabs/datatable-tabs.component';
|
||||||
import { ViewCampaignComponent } from './sms-campaigns/view-campaign/view-campaign.component';
|
import { ViewCampaignComponent } from './sms-campaigns/view-campaign/view-campaign.component';
|
||||||
|
import { ManageFundsComponent } from './manage-funds/manage-funds.component';
|
||||||
|
|
||||||
/** Custom Resolvers */
|
/** Custom Resolvers */
|
||||||
import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver';
|
import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver';
|
||||||
@@ -68,6 +69,7 @@ import { OfficeResolver } from './offices/common-resolvers/office.resolver';
|
|||||||
import { OfficeDatatableResolver } from './offices/common-resolvers/office-datatable.resolver';
|
import { OfficeDatatableResolver } from './offices/common-resolvers/office-datatable.resolver';
|
||||||
import { OfficeDatatablesResolver } from './offices/common-resolvers/office-datatables.resolver';
|
import { OfficeDatatablesResolver } from './offices/common-resolvers/office-datatables.resolver';
|
||||||
import { SmsCampaignResolver } from './sms-campaigns/common-resolvers/sms-campaign.resolver';
|
import { SmsCampaignResolver } from './sms-campaigns/common-resolvers/sms-campaign.resolver';
|
||||||
|
import { ManageFundsResolver } from './manage-funds/manage-funds.resolver';
|
||||||
|
|
||||||
/** Organization Routes */
|
/** Organization Routes */
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
@@ -385,6 +387,14 @@ const routes: Routes = [
|
|||||||
workingDays: WorkingDaysResolver
|
workingDays: WorkingDaysResolver
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'manage-funds',
|
||||||
|
component: ManageFundsComponent,
|
||||||
|
data: { title: extract('Manage Funds Days'), breadcrumb: 'Manage Funds' },
|
||||||
|
resolve: {
|
||||||
|
funds: ManageFundsResolver
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'bulk-import',
|
path: 'bulk-import',
|
||||||
loadChildren: '../bulk-import/bulk-import.module#BulkImportModule'
|
loadChildren: '../bulk-import/bulk-import.module#BulkImportModule'
|
||||||
@@ -453,7 +463,8 @@ const routes: Routes = [
|
|||||||
HolidayResolver,
|
HolidayResolver,
|
||||||
OfficeResolver,
|
OfficeResolver,
|
||||||
OfficeDatatableResolver,
|
OfficeDatatableResolver,
|
||||||
OfficeDatatablesResolver
|
OfficeDatatablesResolver,
|
||||||
|
ManageFundsResolver
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class OrganizationRoutingModule { }
|
export class OrganizationRoutingModule { }
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
|
|
||||||
|
|
||||||
<mat-list-item>
|
<mat-list-item [routerLink]="['manage-funds']">
|
||||||
<mat-icon matListIcon>
|
<mat-icon matListIcon>
|
||||||
<fa-icon icon="money-bill-alt" size="sm"></fa-icon>
|
<fa-icon icon="money-bill-alt" size="sm"></fa-icon>
|
||||||
</mat-icon>
|
</mat-icon>
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import { DatatableTabsComponent } from './offices/view-office/datatable-tabs/dat
|
|||||||
import { SingleRowComponent } from './offices/view-office/datatable-tabs/single-row/single-row.component';
|
import { SingleRowComponent } from './offices/view-office/datatable-tabs/single-row/single-row.component';
|
||||||
import { MultiRowComponent } from './offices/view-office/datatable-tabs/multi-row/multi-row.component';
|
import { MultiRowComponent } from './offices/view-office/datatable-tabs/multi-row/multi-row.component';
|
||||||
import { ViewCampaignComponent } from './sms-campaigns/view-campaign/view-campaign.component';
|
import { ViewCampaignComponent } from './sms-campaigns/view-campaign/view-campaign.component';
|
||||||
|
import { ManageFundsComponent } from './manage-funds/manage-funds.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Organization Module
|
* Organization Module
|
||||||
@@ -89,7 +90,8 @@ import { ViewCampaignComponent } from './sms-campaigns/view-campaign/view-campai
|
|||||||
DatatableTabsComponent,
|
DatatableTabsComponent,
|
||||||
SingleRowComponent,
|
SingleRowComponent,
|
||||||
MultiRowComponent,
|
MultiRowComponent,
|
||||||
ViewCampaignComponent
|
ViewCampaignComponent,
|
||||||
|
ManageFundsComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class OrganizationModule { }
|
export class OrganizationModule { }
|
||||||
|
|||||||
@@ -407,4 +407,28 @@ export class OrganizationService {
|
|||||||
return this.http.put(`/tellers/${tellerId}`, teller);
|
return this.http.put(`/tellers/${tellerId}`, teller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {Observable<any>} Funds data
|
||||||
|
*/
|
||||||
|
getFunds(): Observable<any> {
|
||||||
|
return this.http.get('/funds');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {any} fund Fund to be created.
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
createFund(fund: any): Observable<any> {
|
||||||
|
return this.http.post('/funds', fund);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} fundId Fund Id
|
||||||
|
* @param {any} fundData Fund Data
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
editFund(fundId: string, fundData: any): Observable<any> {
|
||||||
|
return this.http.put(`/funds/${fundId}`, fundData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user