@@ -1,3 +1,4 @@
|
||||
<mifosx-activate-center *ngIf="actions['Activate']"></mifosx-activate-center>
|
||||
<mifosx-center-assign-staff *ngIf="actions['Assign Staff']" ></mifosx-center-assign-staff>
|
||||
<mifosx-close-center *ngIf="actions['Close']"></mifosx-close-center>
|
||||
<mifosx-close-center *ngIf="actions['Close']"></mifosx-close-center>
|
||||
<mifosx-center-attendance *ngIf="actions['Attendance']" ></mifosx-center-attendance>
|
||||
|
||||
@@ -16,11 +16,13 @@ export class CenterActionsComponent {
|
||||
actions: {
|
||||
'Activate': boolean,
|
||||
'Assign Staff': boolean,
|
||||
'Close': boolean
|
||||
'Close': boolean,
|
||||
'Attendance': boolean
|
||||
} = {
|
||||
'Activate': false,
|
||||
'Assign Staff': false,
|
||||
'Close': false
|
||||
'Close': 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.centerData.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 { CenterAttendanceComponent } from './center-attendance.component';
|
||||
|
||||
describe('CenterAttendanceComponent', () => {
|
||||
let component: CenterAttendanceComponent;
|
||||
let fixture: ComponentFixture<CenterAttendanceComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CenterAttendanceComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CenterAttendanceComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/** 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 { CentersService } from 'app/centers/centers.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';
|
||||
|
||||
/**
|
||||
* Center Attendance component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-center-attendance',
|
||||
templateUrl: './center-attendance.component.html',
|
||||
styleUrls: ['./center-attendance.component.scss']
|
||||
})
|
||||
export class CenterAttendanceComponent implements OnInit {
|
||||
|
||||
/** Members data. */
|
||||
membersData: any;
|
||||
/** Center Data */
|
||||
centerData: 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 client members table. */
|
||||
dataSource: {}[] = [];
|
||||
/** Minimum date allowed. */
|
||||
minDate = new Date(2000, 0, 1);
|
||||
/** Maximum date allowed. */
|
||||
maxDate = new Date();
|
||||
|
||||
/**
|
||||
* Retrieves the center members data from `resolve`.
|
||||
* @param {ActivatedRoute} route Route
|
||||
* @param {DatePipe} datePipe Date Pipe
|
||||
* @param {Router} router Router
|
||||
* @param {CentersService} centersService Centers Service
|
||||
* @param {MatDialog} dialog Mat Dialog
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private datePipe: DatePipe,
|
||||
private router: Router,
|
||||
private centersService: CentersService,
|
||||
public dialog: MatDialog) {
|
||||
this.route.data.subscribe(( data: { centersActionData: any }) => {
|
||||
this.centerData = data.centersActionData;
|
||||
this.membersData = data.centersActionData.clients;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the members table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
if (this.membersData !== undefined && this.membersData !== null) {
|
||||
this.dataSource = this.membersData.map((member: any) => ({ clientId: member.id, attendanceType: 1 }));
|
||||
}
|
||||
this.meetingDates = this.centerData.collectionMeetingCalendar.recurringDates
|
||||
.filter((date: any) => new Date(date).getTime() < new Date().getTime());
|
||||
this.getAttendanceOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets attendance type options based on calendar id.
|
||||
*/
|
||||
getAttendanceOptions() {
|
||||
this.centersService.getMeetingsTemplate(this.centerData.id, this.centerData.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.centerData.collectionMeetingCalendar.id,
|
||||
clientsAttendance: this.dataSource,
|
||||
dateFormat,
|
||||
locale
|
||||
};
|
||||
this.centersService.assignCenterAttendance(this.centerData.id, this.centerData.collectionMeetingCalendar.id, data).subscribe(() => {
|
||||
this.router.navigate(['../../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -62,7 +62,7 @@
|
||||
<button mat-raised-button [matMenuTriggerFor]="More"> More </button>
|
||||
<mat-menu #More="matMenu">
|
||||
<span *ngIf="centerViewData.collectionMeetingCalendar">
|
||||
<button mat-menu-item *mifosxHasPermission="'SAVEORUPDATEATTENDANCE_MEETING'"> Attendance </button>
|
||||
<button mat-menu-item *mifosxHasPermission="'SAVEORUPDATEATTENDANCE_MEETING'" (click)="doAction('Attendance')"> Attendance </button>
|
||||
</span>
|
||||
<span *ngIf="!(centerViewData.staffId)">
|
||||
<button mat-menu-item *mifosxHasPermission="'ASSIGNSTAFF_GROUP'" (click)="doAction('Assign Staff')"> Assign Staff </button>
|
||||
|
||||
@@ -59,6 +59,7 @@ export class CentersViewComponent implements OnInit {
|
||||
case 'Activate':
|
||||
case 'Assign Staff':
|
||||
case 'Close':
|
||||
case 'Attendance':
|
||||
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
|
||||
break;
|
||||
case 'Unassign Staff':
|
||||
|
||||
@@ -20,6 +20,7 @@ import { CenterActionsComponent } from './centers-view/center-actions/center-act
|
||||
import { ActivateCenterComponent } from './centers-view/center-actions/activate-center/activate-center.component';
|
||||
import { CenterAssignStaffComponent } from './centers-view/center-actions/center-assign-staff/center-assign-staff.component';
|
||||
import { CloseCenterComponent } from './centers-view/center-actions/close-center/close-center.component';
|
||||
import { CenterAttendanceComponent } from './centers-view/center-actions/center-attendance/center-attendance.component';
|
||||
|
||||
/**
|
||||
* Centers Module
|
||||
@@ -45,7 +46,8 @@ import { CloseCenterComponent } from './centers-view/center-actions/close-center
|
||||
CenterActionsComponent,
|
||||
ActivateCenterComponent,
|
||||
CenterAssignStaffComponent,
|
||||
CloseCenterComponent
|
||||
CloseCenterComponent,
|
||||
CenterAttendanceComponent
|
||||
]
|
||||
})
|
||||
export class CentersModule { }
|
||||
|
||||
@@ -213,4 +213,19 @@ export class CentersService {
|
||||
return this.http.delete(`/centers/${centerId}`);
|
||||
}
|
||||
|
||||
getCentersData(centerId: string) {
|
||||
const httpParams = new HttpParams().set('associations', 'groupMembers,collectionMeetingCalendar');
|
||||
return this.http.get(`/centers/${centerId}`, {params: httpParams});
|
||||
}
|
||||
|
||||
getMeetingsTemplate(centerId: any, calendarId: any): Observable<any> {
|
||||
const httpParams = new HttpParams().set('calenderId', calendarId);
|
||||
return this.http.get(`/centers/${centerId}/meetings/template`);
|
||||
}
|
||||
|
||||
assignCenterAttendance(centerId: any, calendarId: any, data: any): Observable<any> {
|
||||
const httpParams = new HttpParams().set('calenderId', calendarId);
|
||||
return this.http.post(`/centers/${centerId}/meetings`, data, {params: httpParams});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ export class CenterActionsResolver implements Resolve<Object> {
|
||||
switch (actionName) {
|
||||
case 'Assign Staff':
|
||||
return this.centersService.getGroupStaffData(centerId);
|
||||
case 'Attendance':
|
||||
return this.centersService.getCentersData(centerId);
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user