+39
@@ -0,0 +1,39 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="rejectSavingsAccountForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="column">
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Rejected On Date</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="rejectedOnDatePicker" required formControlName="rejectedOnDate">
|
||||
<mat-datepicker-toggle matSuffix [for]="rejectedOnDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #rejectedOnDatePicker></mat-datepicker>
|
||||
<mat-error *ngIf="rejectSavingsAccountForm.controls.rejectedOnDate.hasError('required')">
|
||||
Rejected 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="warn" [disabled]="!rejectSavingsAccountForm.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 { RejectSavingsAccountComponent } from './reject-savings-account.component';
|
||||
|
||||
describe('RejectSavingsAccountComponent', () => {
|
||||
let component: RejectSavingsAccountComponent;
|
||||
let fixture: ComponentFixture<RejectSavingsAccountComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ RejectSavingsAccountComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(RejectSavingsAccountComponent);
|
||||
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';
|
||||
|
||||
/**
|
||||
* Reject Savings Account Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-reject-savings-account',
|
||||
templateUrl: './reject-savings-account.component.html',
|
||||
styleUrls: ['./reject-savings-account.component.scss']
|
||||
})
|
||||
export class RejectSavingsAccountComponent implements OnInit {
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Reject Saving Account form. */
|
||||
rejectSavingsAccountForm: 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 reject savings form.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.createRejectSavingsAccountForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the reject savings account form.
|
||||
*/
|
||||
createRejectSavingsAccountForm() {
|
||||
this.rejectSavingsAccountForm = this.formBuilder.group({
|
||||
'rejectedOnDate': ['', Validators.required],
|
||||
'note': ['']
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the form and rejects 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 prevRejectedOnDate: Date = this.rejectSavingsAccountForm.value.rejectedOnDate;
|
||||
this.rejectSavingsAccountForm.patchValue({
|
||||
rejectedOnDate: this.datePipe.transform(prevRejectedOnDate, dateFormat),
|
||||
});
|
||||
const data = {
|
||||
...this.rejectSavingsAccountForm.value,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.savingsService.executeSavingsAccountCommand(this.accountId, 'reject', data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
<mifosx-approve-savings-account></mifosx-approve-savings-account>
|
||||
<mifosx-approve-savings-account *ngIf="actions['Approve']"></mifosx-approve-savings-account>
|
||||
<mifosx-reject-savings-account *ngIf="actions['Reject']"></mifosx-reject-savings-account>
|
||||
|
||||
@@ -17,8 +17,10 @@ export class SavingAccountActionsComponent {
|
||||
/** Flag object to store possible actions and render appropriate UI to the user */
|
||||
actions: {
|
||||
'Approve': boolean
|
||||
'Reject': boolean
|
||||
} = {
|
||||
'Approve': false
|
||||
'Approve': false,
|
||||
'Reject': false
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,6 +90,7 @@ export class SavingsAccountViewComponent implements OnInit {
|
||||
doAction(name: string) {
|
||||
switch (name) {
|
||||
case 'Approve':
|
||||
case 'Reject':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
case 'Modify Application':
|
||||
|
||||
@@ -26,6 +26,7 @@ import { SavingsAccountTermsStepComponent } from './savings-account-stepper/savi
|
||||
import { SavingsAccountPreviewStepComponent } from './savings-account-stepper/savings-account-preview-step/savings-account-preview-step.component';
|
||||
import { EditSavingsAccountComponent } from './edit-savings-account/edit-savings-account.component';
|
||||
import { ApproveSavingsAccountComponent } from './saving-account-actions/approve-savings-account/approve-savings-account.component';
|
||||
import { RejectSavingsAccountComponent } from './saving-account-actions/reject-savings-account/reject-savings-account.component';
|
||||
|
||||
/**
|
||||
* Savings Module
|
||||
@@ -56,7 +57,8 @@ import { ApproveSavingsAccountComponent } from './saving-account-actions/approve
|
||||
SavingsAccountTermsStepComponent,
|
||||
SavingsAccountPreviewStepComponent,
|
||||
EditSavingsAccountComponent,
|
||||
ApproveSavingsAccountComponent
|
||||
ApproveSavingsAccountComponent,
|
||||
RejectSavingsAccountComponent
|
||||
],
|
||||
providers: [DatePipe]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user