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 b82edef58..0a3927c03 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 @@ -4,4 +4,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 7d6ac6a67..17d112e87 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 @@ -23,13 +23,17 @@ export class SavingAccountActionsComponent { 'Activate': boolean 'Undo Approval': boolean 'Post Interest As On': boolean + 'Assign Staff': boolean + 'Unassign Staff': boolean } = { 'Approve': false, 'Reject': false, 'Withdraw': false, 'Activate': false, 'Undo Approval': false, - 'Post Interest As On': false + 'Post Interest As On': false, + 'Assign Staff': false, + 'Unassign Staff': false }; /** diff --git a/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.html b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.html new file mode 100644 index 000000000..2516d245c --- /dev/null +++ b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.html @@ -0,0 +1,30 @@ +
+ + + +
+ + + + + Unassignment Date + + + + + Unassignment Date is required + + + + + + + + + + +
+ +
+ +
diff --git a/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.scss b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.spec.ts b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.spec.ts new file mode 100644 index 000000000..de775a8ea --- /dev/null +++ b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SavingsAccountUnassignStaffComponent } from './savings-account-unassign-staff.component'; + +describe('SavingsAccountUnassignStaffComponent', () => { + let component: SavingsAccountUnassignStaffComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ SavingsAccountUnassignStaffComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SavingsAccountUnassignStaffComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts new file mode 100644 index 000000000..6013cc02b --- /dev/null +++ b/src/app/savings/saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component.ts @@ -0,0 +1,82 @@ +/** 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 Unassign Staff Component + */ +@Component({ + selector: 'mifosx-savings-account-unassign-staff', + templateUrl: './savings-account-unassign-staff.component.html', + styleUrls: ['./savings-account-unassign-staff.component.scss'] +}) +export class SavingsAccountUnassignStaffComponent implements OnInit { + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Savings Account Unassign Staff form. */ + savingsUnassignStaffForm: 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 savings account unassign staff form. + */ + ngOnInit() { + this.createSavingsUnassignStaffForm(); + } + + /** + * Creates the savings account unassign staff form. + */ + createSavingsUnassignStaffForm() { + this.savingsUnassignStaffForm = this.formBuilder.group({ + 'unassignedDate': ['', Validators.required] + }); + } + + /** + * Submits the form and unassigns staff of 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 prevUnassignmentDate: Date = this.savingsUnassignStaffForm.value.unassignedDate; + this.savingsUnassignStaffForm.patchValue({ + unassignedDate: this.datePipe.transform(prevUnassignmentDate, dateFormat), + }); + const data = { + ...this.savingsUnassignStaffForm.value, + dateFormat, + locale + }; + this.savingsService.executeSavingsAccountCommand(this.accountId, 'unassignSavingsOfficer', data).subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); + } + +} 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 178116f27..10fbfb3b7 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 @@ -105,6 +105,7 @@ export class SavingsAccountViewComponent implements OnInit { case 'Undo Approval': case 'Post Interest As On': case 'Assign Staff': + case 'Unassign Staff': 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 f4f4ae5fe..439a08434 100644 --- a/src/app/savings/savings.module.ts +++ b/src/app/savings/savings.module.ts @@ -32,6 +32,7 @@ import { ActivateSavingsAccountComponent } from './saving-account-actions/activa 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'; +import { SavingsAccountUnassignStaffComponent } from './saving-account-actions/savings-account-unassign-staff/savings-account-unassign-staff.component'; /** * Savings Module @@ -68,7 +69,8 @@ import { SavingsAccountAssignStaffComponent } from './saving-account-actions/sav ActivateSavingsAccountComponent, UndoApprovalSavingsAccountComponent, PostInterestAsOnSavingsAccountComponent, - SavingsAccountAssignStaffComponent + SavingsAccountAssignStaffComponent, + SavingsAccountUnassignStaffComponent ], providers: [DatePipe] })