diff --git a/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.html b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.html new file mode 100644 index 000000000..187ae302c --- /dev/null +++ b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.html @@ -0,0 +1,30 @@ +
+ + + +
+ + + + + Activated On Date + + + + + Activated On Date is required + + + + + + + + + + +
+ +
+ +
diff --git a/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.scss b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.spec.ts b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.spec.ts new file mode 100644 index 000000000..aeced6bba --- /dev/null +++ b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ActivateGroupComponent } from './activate-group.component'; + +describe('ActivateGroupComponent', () => { + let component: ActivateGroupComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ActivateGroupComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ActivateGroupComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.ts b/src/app/groups/groups-view/group-actions/activate-group/activate-group.component.ts new file mode 100644 index 000000000..bdbd07ffa --- /dev/null +++ b/src/app/groups/groups-view/group-actions/activate-group/activate-group.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 { GroupsService } from 'app/groups/groups.service'; + +/** + * Activate Group Component + */ +@Component({ + selector: 'mifosx-activate-group', + templateUrl: './activate-group.component.html', + styleUrls: ['./activate-group.component.scss'] +}) +export class ActivateGroupComponent implements OnInit { + + /** Minimum date allowed. */ + minDate = new Date(2000, 0, 1); + /** Maximum date allowed. */ + maxDate = new Date(); + /** Activate group form. */ + activateGroupForm: FormGroup; + /** Group Account Id */ + groupId: any; + + /** + * @param {FormBuilder} formBuilder Form Builder + * @param {groupsService} groupsService Shares Service + * @param {DatePipe} datePipe Date Pipe + * @param {ActivatedRoute} route Activated Route + * @param {Router} router Router + */ + constructor(private formBuilder: FormBuilder, + private groupsService: GroupsService, + private datePipe: DatePipe, + private route: ActivatedRoute, + private router: Router) { + this.groupId = this.route.parent.snapshot.params['groupId']; + } + + /** + * Creates the activate group form. + */ + ngOnInit() { + this.createActivateGroupForm(); + } + + /** + * Creates the activate group form. + */ + createActivateGroupForm() { + this.activateGroupForm = this.formBuilder.group({ + 'activationDate': ['', Validators.required] + }); + } + + /** + * Submits the form and activates the group, + * if successful redirects to the group. + */ + submit() { + // TODO: Update once language and date settings are setup + const locale = 'en'; + const dateFormat = 'dd MMMM yyyy'; + const prevactivationDate: Date = this.activateGroupForm.value.activationDate; + this.activateGroupForm.patchValue({ + activationDate: this.datePipe.transform(prevactivationDate, dateFormat), + }); + const data = { + ...this.activateGroupForm.value, + dateFormat, + locale + }; + this.groupsService.executeGroupCommand(this.groupId, 'activate', data).subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/groups/groups-view/group-actions/group-actions.component.html b/src/app/groups/groups-view/group-actions/group-actions.component.html index 24b6f096a..a88f23d75 100644 --- a/src/app/groups/groups-view/group-actions/group-actions.component.html +++ b/src/app/groups/groups-view/group-actions/group-actions.component.html @@ -1,2 +1,3 @@ + diff --git a/src/app/groups/groups-view/group-actions/group-actions.component.ts b/src/app/groups/groups-view/group-actions/group-actions.component.ts index 02d0c8e4d..b73a5dc0b 100644 --- a/src/app/groups/groups-view/group-actions/group-actions.component.ts +++ b/src/app/groups/groups-view/group-actions/group-actions.component.ts @@ -16,9 +16,11 @@ export class GroupActionsComponent { actions: { 'Assign Staff': boolean 'Close': boolean + 'Activate': boolean } = { 'Assign Staff': false, - 'Close': false + 'Close': false, + 'Activate': false }; /** diff --git a/src/app/groups/groups-view/groups-view.component.html b/src/app/groups/groups-view/groups-view.component.html index eaeddf3a2..755a68c78 100644 --- a/src/app/groups/groups-view/groups-view.component.html +++ b/src/app/groups/groups-view/groups-view.component.html @@ -54,7 +54,7 @@ -