@@ -3,4 +3,5 @@
|
||||
<mifosx-withdraw-savings-account *ngIf="actions['Withdraw']"></mifosx-withdraw-savings-account>
|
||||
<mifosx-activate-savings-account *ngIf="actions['Activate']"></mifosx-activate-savings-account>
|
||||
<mifosx-undo-approval-savings-account *ngIf="actions['Undo Approval']"></mifosx-undo-approval-savings-account>
|
||||
<mifosx-post-interest-as-on-savings-account *ngIf="actions['Post Interest As On']"></mifosx-post-interest-as-on-savings-account>
|
||||
<mifosx-post-interest-as-on-savings-account *ngIf="actions['Post Interest As On']"></mifosx-post-interest-as-on-savings-account>
|
||||
<mifosx-savings-account-assign-staff [savingsAccountData]="savingsAccountData" *ngIf="actions['Assign Staff']"></mifosx-savings-account-assign-staff>
|
||||
@@ -1,6 +1,7 @@
|
||||
/** Angular Imports */
|
||||
import { Component } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { SavingsService } from '../savings.service';
|
||||
|
||||
/**
|
||||
* Savings account actions component.
|
||||
@@ -12,8 +13,8 @@ import { Router, ActivatedRoute } from '@angular/router';
|
||||
})
|
||||
export class SavingAccountActionsComponent {
|
||||
|
||||
/** Shares Account Data */
|
||||
sharesAccountData: any;
|
||||
/** Savings Account Data */
|
||||
savingsAccountData: any;
|
||||
/** Flag object to store possible actions and render appropriate UI to the user */
|
||||
actions: {
|
||||
'Approve': boolean
|
||||
@@ -33,10 +34,16 @@ export class SavingAccountActionsComponent {
|
||||
|
||||
/**
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {SavingsService} savingsService Savings Service
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
constructor(private route: ActivatedRoute,
|
||||
private savingsService: SavingsService) {
|
||||
const name = this.route.snapshot.params['name'];
|
||||
this.actions[name] = true;
|
||||
const accountId = this.route.parent.snapshot.params['savingAccountId'];
|
||||
this.savingsService.getSavingsAccountAndTemplate(accountId, true).subscribe((response: any) => {
|
||||
this.savingsAccountData = response;
|
||||
this.actions[name] = true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="savingsAssignStaffForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="column">
|
||||
|
||||
<mat-form-field fxFlex="48%">
|
||||
<mat-label>To Savings Officer</mat-label>
|
||||
<mat-select formControlName="toSavingsOfficerId">
|
||||
<mat-option *ngFor="let officer of fieldOfficerData" [value]="officer.id">
|
||||
{{ officer.displayName }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Assignment Date</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="assignmentDatePicker" required formControlName="assignmentDate">
|
||||
<mat-datepicker-toggle matSuffix [for]="assignmentDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #assignmentDatePicker></mat-datepicker>
|
||||
<mat-error *ngIf="savingsAssignStaffForm.controls.assignmentDate.hasError('required')">
|
||||
Assignment Date is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
</mat-card-content>
|
||||
|
||||
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
|
||||
<button type="button" mat-raised-button [routerLink]="['../../']">Cancel</button>
|
||||
<button mat-raised-button color="primary" [disabled]="!savingsAssignStaffForm.valid">Confirm</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { SavingsAccountAssignStaffComponent } from './savings-account-assign-staff.component';
|
||||
|
||||
describe('SavingsAccountAssignStaffComponent', () => {
|
||||
let component: SavingsAccountAssignStaffComponent;
|
||||
let fixture: ComponentFixture<SavingsAccountAssignStaffComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ SavingsAccountAssignStaffComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SavingsAccountAssignStaffComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
/** Custom Services */
|
||||
import { SavingsService } from 'app/savings/savings.service';
|
||||
|
||||
/**
|
||||
* Savings Account Assign Staff Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-savings-account-assign-staff',
|
||||
templateUrl: './savings-account-assign-staff.component.html',
|
||||
styleUrls: ['./savings-account-assign-staff.component.scss']
|
||||
})
|
||||
export class SavingsAccountAssignStaffComponent implements OnInit {
|
||||
|
||||
/** Savings Account Data */
|
||||
@Input() savingsAccountData: any;
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Savings Account Assign Staff form. */
|
||||
savingsAssignStaffForm: FormGroup;
|
||||
/** Savings Account Id */
|
||||
accountId: any;
|
||||
/** Field Officer Data */
|
||||
fieldOfficerData: any;
|
||||
|
||||
/**
|
||||
* @param {FormBuilder} formBuilder Form Builder
|
||||
* @param {SavingsService} savingsService Savings Service
|
||||
* @param {DatePipe} datePipe Date Pipe
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
* @param {Router} router Router
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private savingsService: SavingsService,
|
||||
private datePipe: DatePipe,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
this.accountId = this.route.parent.snapshot.params['savingAccountId'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the savings account assign staff form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.fieldOfficerData = this.savingsAccountData.fieldOfficerOptions;
|
||||
this.createSavingsAssignStaffForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the savings account assign staff form.
|
||||
*/
|
||||
createSavingsAssignStaffForm() {
|
||||
this.savingsAssignStaffForm = this.formBuilder.group({
|
||||
'toSavingsOfficerId': [''],
|
||||
'assignmentDate': ['', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the form and assigns staff the saving account,
|
||||
* if successful redirects to the saving account.
|
||||
*/
|
||||
submit() {
|
||||
// TODO: Update once language and date settings are setup
|
||||
const locale = 'en';
|
||||
const dateFormat = 'dd MMMM yyyy';
|
||||
const prevAssignmentDate: Date = this.savingsAssignStaffForm.value.assignmentDate;
|
||||
this.savingsAssignStaffForm.patchValue({
|
||||
assignmentDate: this.datePipe.transform(prevAssignmentDate, dateFormat),
|
||||
});
|
||||
const data = {
|
||||
...this.savingsAssignStaffForm.value,
|
||||
fromSavingsOfficerId: '',
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.savingsService.executeSavingsAccountCommand(this.accountId, 'assignSavingsOfficer', data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -104,6 +104,7 @@ export class SavingsAccountViewComponent implements OnInit {
|
||||
case 'Activate':
|
||||
case 'Undo Approval':
|
||||
case 'Post Interest As On':
|
||||
case 'Assign Staff':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
case 'Modify Application':
|
||||
|
||||
@@ -31,6 +31,7 @@ import { WithdrawSavingsAccountComponent } from './saving-account-actions/withdr
|
||||
import { ActivateSavingsAccountComponent } from './saving-account-actions/activate-savings-account/activate-savings-account.component';
|
||||
import { UndoApprovalSavingsAccountComponent } from './saving-account-actions/undo-approval-savings-account/undo-approval-savings-account.component';
|
||||
import { PostInterestAsOnSavingsAccountComponent } from './saving-account-actions/post-interest-as-on-savings-account/post-interest-as-on-savings-account.component';
|
||||
import { SavingsAccountAssignStaffComponent } from './saving-account-actions/savings-account-assign-staff/savings-account-assign-staff.component';
|
||||
|
||||
/**
|
||||
* Savings Module
|
||||
@@ -66,7 +67,8 @@ import { PostInterestAsOnSavingsAccountComponent } from './saving-account-action
|
||||
WithdrawSavingsAccountComponent,
|
||||
ActivateSavingsAccountComponent,
|
||||
UndoApprovalSavingsAccountComponent,
|
||||
PostInterestAsOnSavingsAccountComponent
|
||||
PostInterestAsOnSavingsAccountComponent,
|
||||
SavingsAccountAssignStaffComponent
|
||||
],
|
||||
providers: [DatePipe]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user