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 87e3d1336..9c79ddd8e 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 @@ -310,7 +310,7 @@ diff --git a/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.html b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.html new file mode 100644 index 000000000..ed4784f79 --- /dev/null +++ b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.html @@ -0,0 +1,30 @@ +
+ + + +
+ + + + + Activated On Date + + + + + Activated On Date is required + + + + + + + + + + +
+ +
+ +
diff --git a/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.scss b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.spec.ts b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.spec.ts new file mode 100644 index 000000000..ffb77e774 --- /dev/null +++ b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ActivateSharesAccountComponent } from './activate-shares-account.component'; + +describe('ActivateSharesAccountComponent', () => { + let component: ActivateSharesAccountComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ActivateSharesAccountComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ActivateSharesAccountComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts new file mode 100644 index 000000000..86db4c7e7 --- /dev/null +++ b/src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts @@ -0,0 +1,75 @@ +/** 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 { SharesService } from 'app/shares/shares.service'; + +/** + * Activate Shares Account Component + */ +@Component({ + selector: 'mifosx-activate-shares-account', + templateUrl: './activate-shares-account.component.html', + styleUrls: ['./activate-shares-account.component.scss'] +}) +export class ActivateSharesAccountComponent implements OnInit { + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Activate Share Account form. */ + activateSharesAccountForm: FormGroup; + /** Shares Account Id */ + accountId: any; + + constructor(private formBuilder: FormBuilder, + private sharesService: SharesService, + private datePipe: DatePipe, + private route: ActivatedRoute, + private router: Router) { + this.accountId = this.route.parent.parent.snapshot.params['shareAccountId']; + } + + /** + * Creates the activate shares form. + */ + ngOnInit() { + this.createActivateSharesAccountForm(); + } + + /** + * Creates the activate shares account form. + */ + createActivateSharesAccountForm() { + this.activateSharesAccountForm = this.formBuilder.group({ + 'activatedDate': ['', Validators.required] + }); + } + + /** + * Submits the form and activates the share account, + * if successful redirects to the share account. + */ + submit() { + // TODO: Update once language and date settings are setup + const locale = 'en'; + const dateFormat = 'dd MMMM yyyy'; + const prevActivatedDate: Date = this.activateSharesAccountForm.value.activatedDate; + this.activateSharesAccountForm.patchValue({ + activatedDate: this.datePipe.transform(prevActivatedDate, dateFormat), + }); + const data = { + ...this.activateSharesAccountForm.value, + dateFormat, + locale + }; + this.sharesService.executeSharesAccountCommand(this.accountId, 'activate', data).subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/shares/shares-account-actions/shares-account-actions.component.html b/src/app/shares/shares-account-actions/shares-account-actions.component.html index 7a0c4faf0..f41f8e278 100644 --- a/src/app/shares/shares-account-actions/shares-account-actions.component.html +++ b/src/app/shares/shares-account-actions/shares-account-actions.component.html @@ -1,3 +1,4 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/src/app/shares/shares-account-actions/shares-account-actions.component.ts b/src/app/shares/shares-account-actions/shares-account-actions.component.ts index 6b16155aa..aa72dab25 100644 --- a/src/app/shares/shares-account-actions/shares-account-actions.component.ts +++ b/src/app/shares/shares-account-actions/shares-account-actions.component.ts @@ -17,10 +17,12 @@ export class SharesAccountActionsComponent { Approve: boolean Reject: boolean Close: boolean + Activate: boolean } = { Approve: false, Reject: false, - Close: false + Close: false, + Activate: false }; constructor(private route: ActivatedRoute) { diff --git a/src/app/shares/shares-account-view/shares-account-view.component.ts b/src/app/shares/shares-account-view/shares-account-view.component.ts index 8fafc878b..0d4f706bc 100644 --- a/src/app/shares/shares-account-view/shares-account-view.component.ts +++ b/src/app/shares/shares-account-view/shares-account-view.component.ts @@ -94,6 +94,9 @@ export class SharesAccountViewComponent implements OnInit { case 'Close': this.router.navigate(['actions/Close'], { relativeTo: this.route }); break; + case 'Activate': + this.router.navigate(['actions/Activate'], { relativeTo: this.route }); + break; case 'Delete': this.deleteSharesAccount(); break; diff --git a/src/app/shares/shares.module.ts b/src/app/shares/shares.module.ts index 0a0627a02..af0690c94 100644 --- a/src/app/shares/shares.module.ts +++ b/src/app/shares/shares.module.ts @@ -21,6 +21,7 @@ import { SharesAccountActionsComponent } from './shares-account-actions/shares-a import { ApproveSharesAccountComponent } from './shares-account-actions/approve-shares-account/approve-shares-account.component'; import { RejectSharesAccountComponent } from './shares-account-actions/reject-shares-account/reject-shares-account.component'; import { CloseSharesAccountComponent } from './shares-account-actions/close-shares-account/close-shares-account.component'; +import { ActivateSharesAccountComponent } from './shares-account-actions/activate-shares-account/activate-shares-account.component'; /** * Shares Module @@ -48,7 +49,8 @@ import { CloseSharesAccountComponent } from './shares-account-actions/close-shar SharesAccountActionsComponent, ApproveSharesAccountComponent, RejectSharesAccountComponent, - CloseSharesAccountComponent + CloseSharesAccountComponent, + ActivateSharesAccountComponent ], providers: [DatePipe] })