@@ -0,0 +1,30 @@
|
|||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<mat-card>
|
||||||
|
|
||||||
|
<form [formGroup]="activateGroupForm" (ngSubmit)="submit()">
|
||||||
|
|
||||||
|
<mat-card-content>
|
||||||
|
|
||||||
|
<mat-form-field fxFlex>
|
||||||
|
<mat-label>Activated On Date</mat-label>
|
||||||
|
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="activationDatePicker" required formControlName="activationDate">
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="activationDatePicker"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #activationDatePicker></mat-datepicker>
|
||||||
|
<mat-error *ngIf="activateGroupForm.controls.activationDate.hasError('required')">
|
||||||
|
Activated On Date is <strong>required</strong>
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
</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="accent" [disabled]="!activateGroupForm.valid">Confirm</button>
|
||||||
|
</mat-card-actions>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</mat-card>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.container {
|
||||||
|
max-width: 37rem;
|
||||||
|
}
|
||||||
+25
@@ -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<ActivateGroupComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ActivateGroupComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ActivateGroupComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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 });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
<mifosx-group-assign-staff *ngIf="actions['Assign Staff']"></mifosx-group-assign-staff>
|
<mifosx-group-assign-staff *ngIf="actions['Assign Staff']"></mifosx-group-assign-staff>
|
||||||
<mifosx-close-group *ngIf="actions['Close']"></mifosx-close-group>
|
<mifosx-close-group *ngIf="actions['Close']"></mifosx-close-group>
|
||||||
|
<mifosx-activate-group *ngIf="actions['Activate']"></mifosx-activate-group>
|
||||||
|
|||||||
@@ -16,9 +16,11 @@ export class GroupActionsComponent {
|
|||||||
actions: {
|
actions: {
|
||||||
'Assign Staff': boolean
|
'Assign Staff': boolean
|
||||||
'Close': boolean
|
'Close': boolean
|
||||||
|
'Activate': boolean
|
||||||
} = {
|
} = {
|
||||||
'Assign Staff': false,
|
'Assign Staff': false,
|
||||||
'Close': false
|
'Close': false,
|
||||||
|
'Activate': false
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
<mat-card-actions class="group-actions" *ngIf="!(groupViewData.status.value==='Closed')">
|
<mat-card-actions class="group-actions" *ngIf="!(groupViewData.status.value==='Closed')">
|
||||||
|
|
||||||
<span *ngIf="!(groupViewData.status.value==='Active')">
|
<span *ngIf="!(groupViewData.status.value==='Active')">
|
||||||
<button mat-raised-button *mifosxHasPermission="'UPDATE_GROUP'">
|
<button mat-raised-button *mifosxHasPermission="'UPDATE_GROUP'" (click)="doAction('Activate')">
|
||||||
<i class="fa fa-check-sign"></i>Activate</button>
|
<i class="fa fa-check-sign"></i>Activate</button>
|
||||||
</span>
|
</span>
|
||||||
<button mat-raised-button *mifosxHasPermission="'UPDATE_GROUP'">
|
<button mat-raised-button *mifosxHasPermission="'UPDATE_GROUP'">
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export class GroupsViewComponent {
|
|||||||
switch (name) {
|
switch (name) {
|
||||||
case 'Assign Staff':
|
case 'Assign Staff':
|
||||||
case 'Close':
|
case 'Close':
|
||||||
|
case 'Activate':
|
||||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||||
break;
|
break;
|
||||||
case 'Unassign Staff':
|
case 'Unassign Staff':
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { GroupActionsComponent } from './groups-view/group-actions/group-actions
|
|||||||
import { GroupAssignStaffComponent } from './groups-view/group-actions/group-assign-staff/group-assign-staff.component';
|
import { GroupAssignStaffComponent } from './groups-view/group-actions/group-assign-staff/group-assign-staff.component';
|
||||||
import { UnassignStaffDialogComponent } from './groups-view/custom-dialogs/unassign-staff-dialog/unassign-staff-dialog.component';
|
import { UnassignStaffDialogComponent } from './groups-view/custom-dialogs/unassign-staff-dialog/unassign-staff-dialog.component';
|
||||||
import { CloseGroupComponent } from './groups-view/group-actions/close-group/close-group.component';
|
import { CloseGroupComponent } from './groups-view/group-actions/close-group/close-group.component';
|
||||||
|
import { ActivateGroupComponent } from './groups-view/group-actions/activate-group/activate-group.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Groups Module
|
* Groups Module
|
||||||
@@ -52,7 +53,8 @@ import { CloseGroupComponent } from './groups-view/group-actions/close-group/clo
|
|||||||
GroupActionsComponent,
|
GroupActionsComponent,
|
||||||
GroupAssignStaffComponent,
|
GroupAssignStaffComponent,
|
||||||
UnassignStaffDialogComponent,
|
UnassignStaffDialogComponent,
|
||||||
CloseGroupComponent
|
CloseGroupComponent,
|
||||||
|
ActivateGroupComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
UnassignRoleDialogComponent,
|
UnassignRoleDialogComponent,
|
||||||
|
|||||||
Reference in New Issue
Block a user