+39
@@ -0,0 +1,39 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="approveSavingsAccountForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="column">
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Approved On Date</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="approvedOnDatePicker" required formControlName="approvedOnDate">
|
||||
<mat-datepicker-toggle matSuffix [for]="approvedOnDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #approvedOnDatePicker></mat-datepicker>
|
||||
<mat-error *ngIf="approveSavingsAccountForm.controls.approvedOnDate.hasError('required')">
|
||||
Approved On Date is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Note</mat-label>
|
||||
<textarea matInput formControlName="note"></textarea>
|
||||
</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="accent" [disabled]="!approveSavingsAccountForm.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 { ApproveSavingsAccountComponent } from './approve-savings-account.component';
|
||||
|
||||
describe('ApproveSavingsAccountComponent', () => {
|
||||
let component: ApproveSavingsAccountComponent;
|
||||
let fixture: ComponentFixture<ApproveSavingsAccountComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ApproveSavingsAccountComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ApproveSavingsAccountComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } 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';
|
||||
|
||||
/**
|
||||
* Approve Savings Account Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-approve-savings-account',
|
||||
templateUrl: './approve-savings-account.component.html',
|
||||
styleUrls: ['./approve-savings-account.component.scss']
|
||||
})
|
||||
export class ApproveSavingsAccountComponent implements OnInit {
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Approve Savings Account form. */
|
||||
approveSavingsAccountForm: FormGroup;
|
||||
/** Savings Account Id */
|
||||
accountId: 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 approve savings form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createApproveSavingsAccountForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the approve savings account form.
|
||||
*/
|
||||
createApproveSavingsAccountForm() {
|
||||
this.approveSavingsAccountForm = this.formBuilder.group({
|
||||
'approvedOnDate': ['', Validators.required],
|
||||
'note': ['']
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the form and approves 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 prevApprovedOnDate: Date = this.approveSavingsAccountForm.value.approvedOnDate;
|
||||
this.approveSavingsAccountForm.patchValue({
|
||||
approvedOnDate: this.datePipe.transform(prevApprovedOnDate, dateFormat),
|
||||
});
|
||||
const data = {
|
||||
...this.approveSavingsAccountForm.value,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.savingsService.executeSavingsAccountCommand(this.accountId, 'approve', data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,2 @@
|
||||
<div class="container">
|
||||
<mat-card>
|
||||
<mifosx-savings-transactions *ngIf="actions.transaction"></mifosx-savings-transactions>
|
||||
</mat-card>
|
||||
</div>
|
||||
<mifosx-approve-savings-account></mifosx-approve-savings-account>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Component } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
||||
/**
|
||||
* Create savings account actions component.
|
||||
* Savings account actions component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-saving-account-actions',
|
||||
@@ -12,15 +12,21 @@ import { Router, ActivatedRoute } from '@angular/router';
|
||||
})
|
||||
export class SavingAccountActionsComponent {
|
||||
|
||||
/** flag object to store possible actions and render appropriate UI to the user */
|
||||
actions: { transaction: boolean } = { transaction: false };
|
||||
/** Shares Account Data */
|
||||
sharesAccountData: any;
|
||||
/** Flag object to store possible actions and render appropriate UI to the user */
|
||||
actions: {
|
||||
'Approve': boolean
|
||||
} = {
|
||||
'Approve': false
|
||||
};
|
||||
|
||||
constructor(private router: Router,
|
||||
private route: ActivatedRoute) {
|
||||
this.route.params.subscribe(params => {
|
||||
this.actions[params['action']] = true;
|
||||
});
|
||||
/**
|
||||
* @param {ActivatedRoute} route Activated Route
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
const name = this.route.snapshot.params['name'];
|
||||
this.actions[name] = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user