@@ -30,6 +30,8 @@ export class GroupActionsResolver implements Resolve<Object> {
|
||||
switch (actionName) {
|
||||
case 'Assign Staff':
|
||||
return this.groupsService.getGroupData(groupId, 'true');
|
||||
case 'Close':
|
||||
return this.groupsService.getGroupCommandTemplate('close');
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="closeGroupForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
<div fxLayout="column">
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Closed On Date</mat-label>
|
||||
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="closureDatePicker" required formControlName="closureDate">
|
||||
<mat-datepicker-toggle matSuffix [for]="closureDatePicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #closureDatePicker></mat-datepicker>
|
||||
<mat-error *ngIf="closeGroupForm.controls.closureDate.hasError('required')">
|
||||
Closed On Date is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field fxFlex="48%">
|
||||
<mat-label>Closure Reason</mat-label>
|
||||
<mat-select formControlName="closureReasonId">
|
||||
<mat-option *ngFor="let reason of closureData" [value]="reason.id">
|
||||
{{ reason.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-error *ngIf="closeGroupForm.controls.closureReasonId.hasError('required')">
|
||||
CLosure Reason is <strong>required</strong>
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
|
||||
</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="warn" [disabled]="!closeGroupForm.valid">Confirm</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</form>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CloseGroupComponent } from './close-group.component';
|
||||
|
||||
describe('CloseGroupComponent', () => {
|
||||
let component: CloseGroupComponent;
|
||||
let fixture: ComponentFixture<CloseGroupComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CloseGroupComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CloseGroupComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
/** 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';
|
||||
|
||||
/**
|
||||
* Close Group Component
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-close-group',
|
||||
templateUrl: './close-group.component.html',
|
||||
styleUrls: ['./close-group.component.scss']
|
||||
})
|
||||
export class CloseGroupComponent implements OnInit {
|
||||
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
maxDate = new Date();
|
||||
/** Close Share Account form. */
|
||||
closeGroupForm: FormGroup;
|
||||
/** Group Data */
|
||||
closureData: any;
|
||||
/** Group 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.route.data.subscribe((data: { groupActionData: any }) => {
|
||||
this.closureData = data.groupActionData.closureReasons;
|
||||
});
|
||||
this.groupId = this.route.parent.snapshot.params['groupId'];
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.createCloseGroupForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the close group form.
|
||||
*/
|
||||
createCloseGroupForm() {
|
||||
this.closeGroupForm = this.formBuilder.group({
|
||||
'closureDate': ['', Validators.required],
|
||||
'closureReasonId': ['', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the form and closes the group.
|
||||
*/
|
||||
submit() {
|
||||
// TODO: Update once language and date settings are setup
|
||||
const locale = 'en';
|
||||
const dateFormat = 'dd MMMM yyyy';
|
||||
const prevClosedDate: Date = this.closeGroupForm.value.closureDate;
|
||||
this.closeGroupForm.patchValue({
|
||||
closureDate: this.datePipe.transform(prevClosedDate, dateFormat),
|
||||
});
|
||||
const data = {
|
||||
...this.closeGroupForm.value,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.groupsService.executeGroupCommand(this.groupId, 'close', data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
<mifosx-group-assign-staff *ngIf="actions['Assign Staff']"></mifosx-group-assign-staff>
|
||||
<mifosx-close-group *ngIf="actions['Close']"></mifosx-close-group>
|
||||
|
||||
@@ -15,8 +15,10 @@ export class GroupActionsComponent {
|
||||
/** Flag object to store possible actions and render appropriate UI to the user */
|
||||
actions: {
|
||||
'Assign Staff': boolean
|
||||
'Close': boolean
|
||||
} = {
|
||||
'Assign Staff': false
|
||||
'Assign Staff': false,
|
||||
'Close': false
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
<button mat-menu-item *mifosxHasPermission="'UNASSIGNSTAFF_GROUP'"(click)="doAction('Unassign Staff')">Unassign Staff</button></span>
|
||||
<span *ngIf="!(groupViewData.centerId || groupViewData.collectionMeetingCalendar) && groupViewData.status.value==='Active'">
|
||||
<button mat-menu-item *mifosxHasPermission="'CREATE_MEETING'">Attatch Meeting</button></span>
|
||||
<button mat-menu-item *mifosxHasPermission="'CLOSE_GROUP'">Close</button>
|
||||
<button mat-menu-item *mifosxHasPermission="'CLOSE_GROUP'" (click)="doAction('Close')">Close</button>
|
||||
<button mat-menu-item *mifosxHasPermission="'DELETE_GROUP'">Delete</button>
|
||||
</mat-menu>
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ export class GroupsViewComponent {
|
||||
doAction(name: string) {
|
||||
switch (name) {
|
||||
case 'Assign Staff':
|
||||
case 'Close':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
case 'Unassign Staff':
|
||||
|
||||
@@ -23,6 +23,7 @@ import { UnassignRoleDialogComponent } from './groups-view/custom-dialogs/unassi
|
||||
import { GroupActionsComponent } from './groups-view/group-actions/group-actions.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 { CloseGroupComponent } from './groups-view/group-actions/close-group/close-group.component';
|
||||
|
||||
/**
|
||||
* Groups Module
|
||||
@@ -50,7 +51,8 @@ import { UnassignStaffDialogComponent } from './groups-view/custom-dialogs/unass
|
||||
UnassignRoleDialogComponent,
|
||||
GroupActionsComponent,
|
||||
GroupAssignStaffComponent,
|
||||
UnassignStaffDialogComponent
|
||||
UnassignStaffDialogComponent,
|
||||
CloseGroupComponent
|
||||
],
|
||||
entryComponents: [
|
||||
UnassignRoleDialogComponent,
|
||||
|
||||
@@ -72,6 +72,15 @@ export class GroupsService {
|
||||
return this.http.get(`/runreports/GroupSummaryCounts`, { params: httpParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} command Command
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getGroupCommandTemplate(command: string): Observable<any> {
|
||||
const httpParams = new HttpParams().set('command', command);
|
||||
return this.http.get(`/groups/template`, { params: httpParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} groupId Group Id
|
||||
* @param {string} command Command
|
||||
|
||||
Reference in New Issue
Block a user