@@ -28,6 +28,8 @@ export class GroupActionsResolver implements Resolve<Object> {
|
||||
const actionName = route.paramMap.get('name');
|
||||
const groupId = route.paramMap.get('groupId') || route.parent.parent.paramMap.get('groupId');
|
||||
switch (actionName) {
|
||||
case 'Attendance':
|
||||
return this.groupsService.getGroupData(groupId);
|
||||
case 'Assign Staff':
|
||||
return this.groupsService.getGroupData(groupId, 'true');
|
||||
case 'Close':
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
<mifosx-close-group *ngIf="actions['Close']"></mifosx-close-group>
|
||||
<mifosx-activate-group *ngIf="actions['Activate']"></mifosx-activate-group>
|
||||
<mifosx-attach-group-meeting *ngIf="actions['Attach Meeting']"></mifosx-attach-group-meeting>
|
||||
<mifosx-group-attendance *ngIf="actions['Attendance']"></mifosx-group-attendance>
|
||||
|
||||
@@ -18,11 +18,13 @@ export class GroupActionsComponent {
|
||||
'Close': boolean
|
||||
'Activate': boolean
|
||||
'Attach Meeting': boolean
|
||||
'Attendance': boolean
|
||||
} = {
|
||||
'Assign Staff': false,
|
||||
'Close': false,
|
||||
'Activate': false,
|
||||
'Attach Meeting': false,
|
||||
'Attendance': false
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<div class="container">
|
||||
|
||||
<mat-card fxLayout="column" fxLayoutGap="3%">
|
||||
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Meeting Date</mat-label>
|
||||
<mat-select [formControl]="meetingDate">
|
||||
<mat-option *ngFor="let date of meetingDates" [value]="date">
|
||||
{{ date | date }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-hint>Next Meeting on: {{ this.groupData.collectionMeetingCalendar.nextTenRecurringDates[0] | date }}</mat-hint>
|
||||
</mat-form-field>
|
||||
|
||||
<table class="mat-elevation-z1" mat-table [dataSource]="dataSource">
|
||||
|
||||
<ng-container matColumnDef="name">
|
||||
<th mat-header-cell *matHeaderCellDef> Name </th>
|
||||
<td mat-cell *matCellDef="let member"> {{ member.clientId | find:membersData:'id':'displayName' }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="attendance">
|
||||
<th mat-header-cell *matHeaderCellDef> Attendance </th>
|
||||
<td mat-cell *matCellDef="let member" [ngSwitch]="member.attendanceType">
|
||||
<span *ngSwitchCase="1">Present</span>
|
||||
<span *ngSwitchCase="2">Absent</span>
|
||||
<span *ngSwitchCase="3">Approved</span>
|
||||
<span *ngSwitchCase="4">Leave</span>
|
||||
<span *ngSwitchCase="5">Late</span>
|
||||
<button mat-icon-button color="primary"
|
||||
(click)="editAttendance(member)">
|
||||
<fa-icon icon="pen"></fa-icon>
|
||||
</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<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="primary" (click)="submit()">Confirm</button>
|
||||
</mat-card-actions>
|
||||
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.container {
|
||||
max-width: 37rem;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { GroupAttendanceComponent } from './group-attendance.component';
|
||||
|
||||
describe('GroupAttendanceComponent', () => {
|
||||
let component: GroupAttendanceComponent;
|
||||
let fixture: ComponentFixture<GroupAttendanceComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ GroupAttendanceComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(GroupAttendanceComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { FormControl } from '@angular/forms';
|
||||
|
||||
/** Custom Services */
|
||||
import { GroupsService } from 'app/groups/groups.service';
|
||||
|
||||
/** Custom Dialogs */
|
||||
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
|
||||
|
||||
/** Custom Models */
|
||||
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
|
||||
import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
|
||||
|
||||
/**
|
||||
* Group Attendance component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-group-attendance',
|
||||
templateUrl: './group-attendance.component.html',
|
||||
styleUrls: ['./group-attendance.component.scss']
|
||||
})
|
||||
export class GroupAttendanceComponent implements OnInit {
|
||||
|
||||
/** Members data. */
|
||||
membersData: any;
|
||||
/** Group Data */
|
||||
groupData: any;
|
||||
/** Attendance Type Options */
|
||||
attendanceTypeOptions: any;
|
||||
/** Columns to be displayed in member's attendance table. */
|
||||
displayedColumns: string[] = ['name', 'attendance'];
|
||||
/** Start Date Form Control */
|
||||
meetingDate = new FormControl();
|
||||
/** Meeting Dates Data */
|
||||
meetingDates: any[];
|
||||
/** Data source for currencies table. */
|
||||
dataSource: {}[];
|
||||
|
||||
/**
|
||||
* Retrieves the group members data from `resolve`.
|
||||
* @param {ActivatedRoute} route Route
|
||||
* @param {DatePipe} datePipe Date Pipe
|
||||
* @param {Router} router Router
|
||||
* @param {GroupsService} groupsService Groups Service
|
||||
* @param {MatDialog} dialog Mat Dialog
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private datePipe: DatePipe,
|
||||
private router: Router,
|
||||
private groupsService: GroupsService,
|
||||
public dialog: MatDialog) {
|
||||
this.route.data.subscribe(( data: { groupActionData: any }) => {
|
||||
this.groupData = data.groupActionData;
|
||||
this.membersData = data.groupActionData.clientMembers;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the members table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.dataSource = this.membersData.map((member: any) => ({ clientId: member.id, attendanceType: 1 }));
|
||||
this.meetingDates = this.groupData.collectionMeetingCalendar.recurringDates
|
||||
.filter((date: any) => new Date(date).getTime() < new Date().getTime());
|
||||
this.getAttendanceOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets attendance type options based on calendar id.
|
||||
*/
|
||||
getAttendanceOptions() {
|
||||
this.groupsService.getMeetingsTemplate(this.groupData.id, this.groupData.collectionMeetingCalendar.id)
|
||||
.subscribe((response: any) => {
|
||||
this.attendanceTypeOptions = response.attendanceTypeOptions;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits a member's attendance
|
||||
* @param {any} member Client Member
|
||||
*/
|
||||
editAttendance(member: any) {
|
||||
const formfields: FormfieldBase[] = [
|
||||
new SelectBase({
|
||||
controlName: 'attendanceType',
|
||||
label: 'Attendance',
|
||||
value: member.attendanceType,
|
||||
options: { label: 'value', value: 'id', data: this.attendanceTypeOptions },
|
||||
required: false
|
||||
}),
|
||||
];
|
||||
const data = {
|
||||
title: 'Assign Member Attendance',
|
||||
layout: { addButtonText: 'Confirm' },
|
||||
formfields: formfields
|
||||
};
|
||||
const memberAttendanceDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||
memberAttendanceDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.data) {
|
||||
const updatedMemeber = { ...member, ...response.data.value };
|
||||
this.dataSource.splice(this.dataSource.indexOf(member), 1, updatedMemeber);
|
||||
this.dataSource = this.dataSource.concat([]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns Client Members Attendance
|
||||
*/
|
||||
submit() {
|
||||
// TODO: Update once language and date settings are setup
|
||||
const locale = 'en';
|
||||
const dateFormat = 'dd MMMM yyyy';
|
||||
const prevMeetingDate: Date = new Date(this.meetingDate.value);
|
||||
this.meetingDate.patchValue(this.datePipe.transform(prevMeetingDate, dateFormat));
|
||||
const data = {
|
||||
meetingDate: this.meetingDate.value,
|
||||
calendarId: this.groupData.collectionMeetingCalendar.id,
|
||||
clientsAttendance: this.dataSource,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.groupsService.assignGroupAttendance(this.groupData.id, this.groupData.collectionMeetingCalendar.id, data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,7 +78,7 @@
|
||||
<button mat-raised-button [matMenuTriggerFor]="More">More</button>
|
||||
<mat-menu #More="matMenu">
|
||||
<span *ngIf="groupViewData.collectionMeetingCalendar">
|
||||
<button mat-menu-item *mifosxHasPermission="'SAVEORUPDATEATTENDANCE_MEETING'">Attendance</button></span>
|
||||
<button mat-menu-item *mifosxHasPermission="'SAVEORUPDATEATTENDANCE_MEETING'" (click)="doAction('Attendance')">Attendance</button></span>
|
||||
<span *ngIf="!groupViewData.staffId">
|
||||
<button mat-menu-item *mifosxHasPermission="'ASSIGNSTAFF_GROUP'" (click)="doAction('Assign Staff')">Assign Staff</button></span>
|
||||
<span *ngIf="groupViewData.staffId">
|
||||
|
||||
@@ -49,6 +49,7 @@ export class GroupsViewComponent {
|
||||
case 'Close':
|
||||
case 'Activate':
|
||||
case 'Attach Meeting':
|
||||
case 'Attendance':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
case 'Edit':
|
||||
|
||||
@@ -27,6 +27,7 @@ import { CloseGroupComponent } from './groups-view/group-actions/close-group/clo
|
||||
import { ActivateGroupComponent } from './groups-view/group-actions/activate-group/activate-group.component';
|
||||
import { EditGroupComponent } from './edit-group/edit-group.component';
|
||||
import { AttachGroupMeetingComponent } from './groups-view/group-actions/attach-group-meeting/attach-group-meeting.component';
|
||||
import { GroupAttendanceComponent } from './groups-view/group-actions/group-attendance/group-attendance.component';
|
||||
|
||||
/**
|
||||
* Groups Module
|
||||
@@ -58,7 +59,8 @@ import { AttachGroupMeetingComponent } from './groups-view/group-actions/attach-
|
||||
CloseGroupComponent,
|
||||
ActivateGroupComponent,
|
||||
EditGroupComponent,
|
||||
AttachGroupMeetingComponent
|
||||
AttachGroupMeetingComponent,
|
||||
GroupAttendanceComponent
|
||||
],
|
||||
entryComponents: [
|
||||
UnassignRoleDialogComponent,
|
||||
|
||||
@@ -106,8 +106,9 @@ export class GroupsService {
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
unAssignRoleCommand(groupId: string, roleId: any): Observable<any> {
|
||||
const httpParams = new HttpParams().set('command', 'unassignRole')
|
||||
.set('roleId', roleId);
|
||||
const httpParams = new HttpParams()
|
||||
.set('command', 'unassignRole')
|
||||
.set('roleId', roleId);
|
||||
return this.http.post(`/groups/${groupId}`, {}, { params: httpParams });
|
||||
}
|
||||
|
||||
@@ -249,4 +250,24 @@ export class GroupsService {
|
||||
return this.http.post(`/groups/${groupId}/calendars`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} groupId Group Id
|
||||
* @param {any} calendarId Calendar Id
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
getMeetingsTemplate(groupId: any, calendarId: any): Observable<any> {
|
||||
const httpParams = new HttpParams().set('calenderId', calendarId);
|
||||
return this.http.get(`/groups/${groupId}/meetings/template`, { params: httpParams });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} groupId Group Id
|
||||
* @param {any} calendarId Calendar Id
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
assignGroupAttendance(groupId: any, calendarId: any, data: any): Observable<any> {
|
||||
const httpParams = new HttpParams().set('calenderId', calendarId);
|
||||
return this.http.post(`/groups/${groupId}/meetings`, data, { params: httpParams });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user