diff --git a/src/app/clients/clients-view/general-tab/general-tab.component.html b/src/app/clients/clients-view/general-tab/general-tab.component.html index 1e4a9a20a..41807552a 100644 --- a/src/app/clients/clients-view/general-tab/general-tab.component.html +++ b/src/app/clients/clients-view/general-tab/general-tab.component.html @@ -231,7 +231,8 @@ diff --git a/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.html b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.html new file mode 100644 index 000000000..6820a0d29 --- /dev/null +++ b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.html @@ -0,0 +1,30 @@ +
+ + + +
+ + + + + Activated On Date + + + + + Activated On Date is required + + + + + + + + + + +
+ +
+ +
diff --git a/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.scss b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.spec.ts b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.spec.ts new file mode 100644 index 000000000..b89477bbf --- /dev/null +++ b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ActivateSavingsAccountComponent } from './activate-savings-account.component'; + +describe('ActivateSavingsAccountComponent', () => { + let component: ActivateSavingsAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ActivateSavingsAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ActivateSavingsAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts new file mode 100644 index 000000000..fe2234cf4 --- /dev/null +++ b/src/app/savings/saving-account-actions/activate-savings-account/activate-savings-account.component.ts @@ -0,0 +1,82 @@ +/** 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'; + +/** + * Activate Savings Account Component + */ +@Component({ + selector: 'mifosx-activate-savings-account', + templateUrl: './activate-savings-account.component.html', + styleUrls: ['./activate-savings-account.component.scss'] +}) +export class ActivateSavingsAccountComponent implements OnInit { + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Activate Savings Account form. */ + activateSavingsAccountForm: 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 activate savings form. + */ + ngOnInit() { + this.createActivateSavingsAccountForm(); + } + + /** + * Creates the activate savings account form. + */ + createActivateSavingsAccountForm() { + this.activateSavingsAccountForm = this.formBuilder.group({ + 'activatedOnDate': ['', Validators.required] + }); + } + + /** + * Submits the form and activates 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 prevActivatedOnDate: Date = this.activateSavingsAccountForm.value.activatedOnDate; + this.activateSavingsAccountForm.patchValue({ + activatedOnDate: this.datePipe.transform(prevActivatedOnDate, dateFormat), + }); + const data = { + ...this.activateSavingsAccountForm.value, + dateFormat, + locale + }; + this.savingsService.executeSavingsAccountCommand(this.accountId, 'activate', data).subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/savings/saving-account-actions/saving-account-actions.component.html b/src/app/savings/saving-account-actions/saving-account-actions.component.html index ac1f0c4e9..005a487d4 100644 --- a/src/app/savings/saving-account-actions/saving-account-actions.component.html +++ b/src/app/savings/saving-account-actions/saving-account-actions.component.html @@ -1,4 +1,5 @@ + \ No newline at end of file diff --git a/src/app/savings/saving-account-actions/saving-account-actions.component.ts b/src/app/savings/saving-account-actions/saving-account-actions.component.ts index 6f814ddd6..ef0869695 100644 --- a/src/app/savings/saving-account-actions/saving-account-actions.component.ts +++ b/src/app/savings/saving-account-actions/saving-account-actions.component.ts @@ -19,10 +19,12 @@ export class SavingAccountActionsComponent { 'Approve': boolean 'Reject': boolean 'Withdraw': boolean + 'Activate': boolean } = { 'Approve': false, 'Reject': false, - 'Withdraw': false + 'Withdraw': false, + 'Activate': false }; /** diff --git a/src/app/savings/savings-account-view/savings-account-view.component.ts b/src/app/savings/savings-account-view/savings-account-view.component.ts index ec3ab582a..0b5033d9f 100644 --- a/src/app/savings/savings-account-view/savings-account-view.component.ts +++ b/src/app/savings/savings-account-view/savings-account-view.component.ts @@ -101,6 +101,7 @@ export class SavingsAccountViewComponent implements OnInit { case 'Approve': case 'Reject': case 'Withdraw': + case 'Activate': this.router.navigate([`actions/${name}`], { relativeTo: this.route }); break; case 'Modify Application': diff --git a/src/app/savings/savings.module.ts b/src/app/savings/savings.module.ts index b705117fa..76c451c65 100644 --- a/src/app/savings/savings.module.ts +++ b/src/app/savings/savings.module.ts @@ -28,6 +28,7 @@ import { EditSavingsAccountComponent } from './edit-savings-account/edit-savings 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'; import { WithdrawSavingsAccountComponent } from './saving-account-actions/withdraw-savings-account/withdraw-savings-account.component'; +import { ActivateSavingsAccountComponent } from './saving-account-actions/activate-savings-account/activate-savings-account.component'; /** * Savings Module @@ -60,7 +61,8 @@ import { WithdrawSavingsAccountComponent } from './saving-account-actions/withdr EditSavingsAccountComponent, ApproveSavingsAccountComponent, RejectSavingsAccountComponent, - WithdrawSavingsAccountComponent + WithdrawSavingsAccountComponent, + ActivateSavingsAccountComponent ], providers: [DatePipe] })