refactor: groups module (#1197)

See: #1196
This commit is contained in:
Karan Takalkar
2020-08-12 19:22:24 +05:30
committed by GitHub
parent c6ee2a062f
commit cc80bd9577
22 changed files with 121 additions and 101 deletions
@@ -15,12 +15,12 @@ import { GroupsService } from '../groups.service';
export class GroupActionsResolver implements Resolve<Object> {
/**
* @param {GroupsService} groupsService Savings service.
* @param {GroupsService} groupsService Groups service.
*/
constructor(private groupsService: GroupsService) { }
/**
* Returns the Savings account actions data.
* Returns the group actions data.
* @param {ActivatedRouteSnapshot} route Route Snapshot
* @returns {Observable<any>}
*/
@@ -21,7 +21,7 @@ export class EditGroupComponent implements OnInit {
minDate = new Date(2000, 0, 1);
/** Maximum date allowed. */
maxDate = new Date();
/** Group form. */
/** Edit Group form. */
editGroupForm: FormGroup;
/** Staff data. */
staffData: any;
@@ -51,7 +51,7 @@ export class EditGroupComponent implements OnInit {
}
/**
* Creates and sets the group form.
* Creates and sets the edit group form.
*/
ngOnInit() {
this.createEditGroupForm();
@@ -64,7 +64,7 @@ export class EditGroupComponent implements OnInit {
}
/**
* Creates the group form.
* Creates the edit group form.
*/
createEditGroupForm() {
this.editGroupForm = this.formBuilder.group({
@@ -89,7 +89,7 @@ export class EditGroupComponent implements OnInit {
}
/**
* Submits the group form and creates group,
* Submits the group form and edits group,
* if successful redirects to groups.
*/
submit() {
@@ -38,7 +38,8 @@
<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" [disabled]="!groupsAddRoleForm.valid">Confirm</button>
<button mat-raised-button color="primary" [disabled]="!groupsAddRoleForm.valid"
*mifosxHasPermission="'ASSIGNROLE_GROUP'">Confirm</button>
</mat-card-actions>
</form>
@@ -18,7 +18,7 @@ export class AddRoleComponent implements OnInit {
/** Groups Add Role Form */
groupsAddRoleForm: FormGroup;
/** Client Menmber Data */
/** Client Member Data */
clientMemberData: any;
/** Role Data */
roleData: any;
@@ -23,12 +23,12 @@ export class ActivateGroupComponent implements OnInit {
maxDate = new Date();
/** Activate group form. */
activateGroupForm: FormGroup;
/** Group Account Id */
/** Group Id */
groupId: any;
/**
* @param {FormBuilder} formBuilder Form Builder
* @param {groupsService} groupsService Shares Service
* @param {groupsService} groupsService Groups Service
* @param {DatePipe} datePipe Date Pipe
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
@@ -41,9 +41,6 @@ export class ActivateGroupComponent implements OnInit {
this.groupId = this.route.parent.snapshot.params['groupId'];
}
/**
* Creates the activate group form.
*/
ngOnInit() {
this.createActivateGroupForm();
}
@@ -64,7 +64,8 @@
<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" [disabled]="!groupMeetingForm.valid" (click)="submit()">Submit</button>
<button mat-raised-button color="primary" [disabled]="!groupMeetingForm.valid" (click)="submit()"
*mifosxHasPermission="'CREATE_MEETING'">Submit</button>
</mat-card-actions>
</form>
@@ -26,7 +26,7 @@
</mat-option>
</mat-select>
<mat-error *ngIf="closeGroupForm.controls.closureReasonId.hasError('required')">
CLosure Reason is <strong>required</strong>
Closure Reason is <strong>required</strong>
</mat-error>
</mat-form-field>
@@ -21,9 +21,9 @@ export class CloseGroupComponent implements OnInit {
minDate = new Date(2000, 0, 1);
/** Maximum date allowed. */
maxDate = new Date();
/** Close Share Account form. */
/** Close Group form. */
closeGroupForm: FormGroup;
/** Group Data */
/** Group Closure Data */
closureData: any;
/** Group Id */
groupId: any;
@@ -36,7 +36,8 @@
<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" [disabled]="!groupEditMeetingScheduleForm.valid" (click)="submit()">Submit</button>
<button mat-raised-button color="primary" [disabled]="!groupEditMeetingScheduleForm.valid" (click)="submit()"
*mifosxHasPermission="'CREATE_MEETING'">Submit</button>
</mat-card-actions>
</form>
@@ -71,7 +71,8 @@
<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" [disabled]="!groupEditMeetingForm.valid" (click)="submit()">Submit</button>
<button mat-raised-button color="primary" [disabled]="!groupEditMeetingForm.valid" (click)="submit()"
*mifosxHasPermission="'CREATE_MEETING'">Submit</button>
</mat-card-actions>
</form>
@@ -37,6 +37,7 @@ export class GroupActionsComponent {
/**
* @param {ActivatedRoute} route Activated Route
* @param {Router} router Router
*/
constructor(private route: ActivatedRoute,
private router: Router) {
@@ -18,7 +18,7 @@ export class GroupAssignStaffComponent implements OnInit {
/** Group Assign Staff form. */
groupAssignStaffForm: FormGroup;
/** Field Officer Data */
/** Staff Data */
staffData: any;
/** Group Data */
groupData: any;
@@ -39,9 +39,6 @@ export class GroupAssignStaffComponent implements OnInit {
});
}
/**
* Creates the group assign staff form.
*/
ngOnInit() {
this.staffData = this.groupData.staffOptions;
this.createGroupAssignStaffForm();
@@ -41,7 +41,8 @@
<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>
<button mat-raised-button color="primary" (click)="submit()"
*mifosxHasPermission="'SAVEORUPDATEATTENDANCE_MEETING'">Confirm</button>
</mat-card-actions>
</mat-card>
@@ -69,8 +69,9 @@
</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="primary" [disabled]="!transferClientsForm.valid" (click)="submit()">Submit</button>
<button type="button" mat-raised-button [routerLink]="['../../']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!transferClientsForm.valid" (click)="submit()"
*mifosxHasPermission="'TRANSFERCLIENTS_GROUP'">Submit</button>
</mat-card-actions>
</form>
@@ -24,7 +24,7 @@ export class GroupTransferClientsComponent implements OnInit, AfterViewInit {
groupsData: any = [];
/** Staff data. */
staffData: any;
/** Group Members. */
/** Client Members. */
clientMembers: any[] = [];
/**
@@ -11,7 +11,9 @@ import { GroupsService } from 'app/groups/groups.service';
import { ClientsService } from 'app/clients/clients.service';
import { MatDialog } from '@angular/material';
/**
* Manage Group Members Component
*/
@Component({
selector: 'mifosx-manage-group-members',
templateUrl: './manage-group-members.component.html',
@@ -25,7 +27,7 @@ export class ManageGroupMembersComponent implements AfterViewInit {
clientsData: any = [];
/** Client Members. */
clientMembers: any[] = [];
/** ClientChoice. */
/** Client Choice. */
clientChoice = new FormControl('');
/**
@@ -72,7 +74,8 @@ export class ManageGroupMembersComponent implements AfterViewInit {
/**
* Remove client.
* @param index Client's array index.
* @param {number} index Client's array index.
* @param {any} client Client
*/
removeClient(index: number, client: any) {
const removeMemberDialogRef = this.dialog.open(DeleteDialogComponent, {
@@ -84,7 +84,7 @@
<span *ngIf="groupViewData.staffId">
<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'" (click)="doAction('Attach Meeting')">Attatch Meeting</button></span>
<button mat-menu-item *mifosxHasPermission="'CREATE_MEETING'" (click)="doAction('Attach Meeting')">Attach Meeting</button></span>
<button mat-menu-item *mifosxHasPermission="'CLOSE_GROUP'" (click)="doAction('Close')">Close</button>
<button mat-menu-item *mifosxHasPermission="'DELETE_GROUP'" (click)="doAction('Delete')">Delete</button>
</mat-menu>
@@ -28,6 +28,9 @@ export class GroupsViewComponent {
/**
* Fetches group data from `resolve`
* @param {ActivatedRoute} route Activated Route
* @param {GroupsService} groupsService Groups Service
* @param {Router} router Router
* @param {MatDialog} dialog Dialog
*/
constructor(private route: ActivatedRoute,
private groupsService: GroupsService,
@@ -41,6 +41,9 @@ export class NotesTabComponent implements OnInit {
/**
* Fetches notes data from `resolve`
* @param {Activated Route} route Activated Route.
* @param {FormBuilder} formBuilder FormBuilder
* @param {GroupsService} groupsService Groups Service
* @param {MatDialog} dialog MatDialog
* @param {AuthenticationService} authenticationService Authentication Service.
*/
constructor(private route: ActivatedRoute,
+2 -1
View File
@@ -1,4 +1,5 @@
<mat-card class="container">
<div fxLayout="row" fxLayoutAlign="start center">
<div class="search-box">
<mat-form-field>
@@ -10,7 +11,7 @@
<button mat-raised-button color="primary" [routerLink]="['../', 'organization', 'bulk-import', 'Groups']">
<fa-icon icon="download"></fa-icon>&nbsp;&nbsp;Import Group
</button>
<button mat-raised-button color="primary" [routerLink]="['create']">
<button mat-raised-button color="primary" [routerLink]="['create']" *mifosxHasPermission="'CREATE_GROUP'">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp;Create Group
</button>
</div>
+3 -1
View File
@@ -2,7 +2,6 @@
import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
import { MatPaginator, MatSort, MatCheckbox } from '@angular/material';
import { FormControl } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
/** rxjs Imports */
import { merge } from 'rxjs';
@@ -44,6 +43,9 @@ export class GroupsComponent implements OnInit, AfterViewInit {
/** Sorter for groups table. */
@ViewChild(MatSort) sort: MatSort;
/**
* @param {GroupsService} groupsService Groups Service
*/
constructor(private groupsService: GroupsService) { }
ngOnInit() {
+75 -68
View File
@@ -4,7 +4,6 @@ import { HttpClient, HttpParams } from '@angular/common/http';
/** rxjs Imports */
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
/**
* Groups service.
@@ -19,24 +18,6 @@ export class GroupsService {
*/
constructor(private http: HttpClient) { }
/**
* @param {string} orderBy Property by which entries should be sorted.
* @param {string} sortOrder Sort order: ascending or descending.
* @param {string} name Filter value for groups names.
* @returns {Observable<any>} Groups.
*/
getFilteredGroups(orderBy: string, sortOrder: string, name: string, officeId?: any, orphansOnly?: any): Observable<any> {
let httpParams = new HttpParams()
.set('name', name)
.set('sortOrder', sortOrder)
.set('orderBy', orderBy);
if (officeId) {
httpParams = httpParams.set('officeId', officeId);
}
httpParams = orphansOnly ? httpParams.set('orphansOnly', orphansOnly) : httpParams;
return this.http.get('/groups', { params: httpParams });
}
/**
* @param {any} filterBy Properties by which entries should be filtered.
* @param {string} orderBy Property by which entries should be sorted.
@@ -61,25 +42,38 @@ export class GroupsService {
return this.http.get('/groups', { params: httpParams });
}
/**
* @param {string} orderBy Property by which entries should be sorted.
* @param {string} sortOrder Sort order: ascending or descending.
* @param {string} name Filter value for groups names.
* @param {any} officeId? Office Id.
* @param {any} orphansOnly? Orphans Only.
* @returns {Observable<any>} Groups.
*/
getFilteredGroups(orderBy: string, sortOrder: string, name: string, officeId?: any, orphansOnly?: any): Observable<any> {
let httpParams = new HttpParams()
.set('name', name)
.set('sortOrder', sortOrder)
.set('orderBy', orderBy);
if (officeId) {
httpParams = httpParams.set('officeId', officeId);
}
httpParams = orphansOnly ? httpParams.set('orphansOnly', orphansOnly) : httpParams;
return this.http.get('/groups', { params: httpParams });
}
/**
* @param {number} officeId Office Id of office to get groups for.
* @returns {Observable<any>}
*/
getGroupsByOfficeId(officeId: number): Observable<any> {
const httpParams = new HttpParams().set('officeId', officeId.toString());
return this.http.get('/groups', { params: httpParams } );
const httpParams = new HttpParams().set('officeId', officeId.toString());
return this.http.get('/groups', { params: httpParams } );
}
/**
* @param {string} groupId shares account Id
* @returns {Observable<any>}
*/
deleteGroup(groupId: string): Observable<any> {
return this.http.delete(`/groups/${groupId}`);
}
/**
* @param groupId Group Id of group to get data for.
* @param {string} groupId Group Id of group to get data for.
* @param {string} template? Is template data required.
* @returns {Observable<any>} Group data.
*/
getGroupData(groupId: string, template?: string): Observable<any> {
@@ -98,38 +92,6 @@ 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
* @param {any} roleId Role Id
* @returns {Observable<any>}
*/
executeGroupCommand(groupId: string, command: string, data: any): Observable<any> {
const httpParams = new HttpParams().set('command', command);
return this.http.post(`/groups/${groupId}`, data, { params: httpParams });
}
/**
* @param {string} groupId Group Id
* @param {any} roleId Role Id
* @returns {Observable<any>}
*/
unAssignRoleCommand(groupId: string, roleId: any): Observable<any> {
const httpParams = new HttpParams()
.set('command', 'unassignRole')
.set('roleId', roleId);
return this.http.post(`/groups/${groupId}`, {}, { params: httpParams });
}
/**
* @param groupId Group Id of group to get data for.
* @returns {Observable<any>} Group Accounts data.
@@ -225,14 +187,35 @@ export class GroupsService {
}
/**
* @param {number} officeId Office Id of office to get staff for.
* @param {any} command Command
* @returns {Observable<any>} Group Command Template
*/
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
* @param {any} data Command payload
* @returns {Observable<any>}
*/
getStaff(id: number): Observable<any> {
executeGroupCommand(groupId: string, command: string, data: any): Observable<any> {
const httpParams = new HttpParams().set('command', command);
return this.http.post(`/groups/${groupId}`, data, { params: httpParams });
}
/**
* @param {string} groupId Group Id
* @param {any} roleId Role Id
* @returns {Observable<any>}
*/
unAssignRoleCommand(groupId: string, roleId: any): Observable<any> {
const httpParams = new HttpParams()
.set('officeId', id.toString())
.set('staffInSelectedOfficeOnly', 'true');
return this.http.get('/groups/template', { params: httpParams });
.set('command', 'unassignRole')
.set('roleId', roleId);
return this.http.post(`/groups/${groupId}`, {}, { params: httpParams });
}
/**
@@ -244,7 +227,7 @@ export class GroupsService {
}
/**
* @param {any} group Group to be created.
* @param {any} group Group to be updated.
* @param {any} groupId Group Id
* @returns {Observable<any>}
*/
@@ -252,6 +235,14 @@ export class GroupsService {
return this.http.put(`/groups/${groupId}`, group);
}
/**
* @param {string} groupId group Id
* @returns {Observable<any>}
*/
deleteGroup(groupId: string): Observable<any> {
return this.http.delete(`/groups/${groupId}`);
}
/**
* @param {any} groupId Group Id
* @returns {Observable<any>}
@@ -262,6 +253,7 @@ export class GroupsService {
/**
* @param {any} groupId Group Id
* @param {any} calendarId Calendar Id
* @returns {Observable<any>}
*/
getGroupCalendarAndTemplate(groupId: any, calendarId: any): Observable<any> {
@@ -271,6 +263,7 @@ export class GroupsService {
/**
* @param {any} groupId Group Id
* @param {any} data Group meeting data
* @returns {Observable<any>}
*/
createGroupMeeting(groupId: any, data: any): Observable<any> {
@@ -279,6 +272,8 @@ export class GroupsService {
/**
* @param {any} groupId Group Id
* @param {any} data Meeting Data
* @param {any} calendarId Calendar Id
* @returns {Observable<any>}
*/
updateGroupMeeting(groupId: any, data: any, calendarId: any): Observable<any> {
@@ -298,6 +293,7 @@ export class GroupsService {
/**
* @param {any} groupId Group Id
* @param {any} calendarId Calendar Id
* @param {any} data Attendance Data
* @returns {Observable<any>}
*/
assignGroupAttendance(groupId: any, calendarId: any, data: any): Observable<any> {
@@ -305,4 +301,15 @@ export class GroupsService {
return this.http.post(`/groups/${groupId}/meetings`, data, { params: httpParams });
}
/**
* @param {number} id Office Id of office to get staff for.
* @returns {Observable<any>} Staff Data for group.
*/
getStaff(id: number): Observable<any> {
const httpParams = new HttpParams()
.set('officeId', id.toString())
.set('staffInSelectedOfficeOnly', 'true');
return this.http.get('/groups/template', { params: httpParams });
}
}