diff --git a/src/app/groups/common-resolvers/group-actions.resolver.ts b/src/app/groups/common-resolvers/group-actions.resolver.ts index 603782405..4345209fc 100644 --- a/src/app/groups/common-resolvers/group-actions.resolver.ts +++ b/src/app/groups/common-resolvers/group-actions.resolver.ts @@ -30,6 +30,7 @@ export class GroupActionsResolver implements Resolve { switch (actionName) { case 'Attendance': case 'Manage Members': + case 'Transfer Clients': return this.groupsService.getGroupData(groupId); case 'Assign Staff': return this.groupsService.getGroupData(groupId, 'true'); diff --git a/src/app/groups/groups-view/group-actions/group-actions.component.html b/src/app/groups/groups-view/group-actions/group-actions.component.html index b2adb0903..08ee40459 100644 --- a/src/app/groups/groups-view/group-actions/group-actions.component.html +++ b/src/app/groups/groups-view/group-actions/group-actions.component.html @@ -6,3 +6,4 @@ + diff --git a/src/app/groups/groups-view/group-actions/group-actions.component.ts b/src/app/groups/groups-view/group-actions/group-actions.component.ts index 82781f074..31407d910 100644 --- a/src/app/groups/groups-view/group-actions/group-actions.component.ts +++ b/src/app/groups/groups-view/group-actions/group-actions.component.ts @@ -22,6 +22,7 @@ export class GroupActionsComponent { 'Manage Members': boolean 'Edit Meeting': boolean 'Edit Meeting Schedule': boolean + 'Transfer Clients': boolean } = { 'Assign Staff': false, 'Close': false, @@ -30,7 +31,8 @@ export class GroupActionsComponent { 'Attendance': false, 'Manage Members': false, 'Edit Meeting': false, - 'Edit Meeting Schedule': false + 'Edit Meeting Schedule': false, + 'Transfer Clients': false }; /** diff --git a/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.html b/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.html new file mode 100644 index 000000000..2b35033df --- /dev/null +++ b/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.html @@ -0,0 +1,80 @@ +
+ + + +
+ + + +
+ + + Select Client Members for Transfer + + + {{ member.displayName }} + + + + Office is required + + + + + Inherit Group Loan Officer? + + + + Destination Group + + + Destination Group is required + + + +
+ + + + {{ group.name }} + + + +
+
+
Destination Group Details
+
+
+
Name
+
{{transferClientsForm.get('destinationGroupId').value.name}}
+
+
+
Id
+
{{transferClientsForm.get('destinationGroupId').value.id}}
+
+
+
Activation Date
+
{{(transferClientsForm.get('destinationGroupId').value.activationDate | date) || 'Not Activated'}}
+
+
+
Staff
+
{{transferClientsForm.get('destinationGroupId').value.staffName || 'Unassigned'}}
+
+
+
External Id
+
{{transferClientsForm.get('destinationGroupId').value.externalId || 'Unassigned'}}
+
+
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.scss b/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.scss new file mode 100644 index 000000000..f231d1299 --- /dev/null +++ b/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.scss @@ -0,0 +1,26 @@ +.container { + max-width: 37rem; + } + +.mat-table { + display: block; + font-family: Tahoma, Verdana; + width: 100% +} + +.mat-row, +.mat-header-row { + display: flex; + border-bottom-width: 1px; + border-bottom-style: solid; + align-items: center; + min-height: 30px; + padding: 0 24px; +} + +.mat-cell, +.mat-header-cell { + flex: 1; + overflow: hidden; + word-wrap: break-word; +} diff --git a/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.spec.ts b/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.spec.ts new file mode 100644 index 000000000..7fee6bb40 --- /dev/null +++ b/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GroupTransferClientsComponent } from './group-transfer-clients.component'; + +describe('GroupTransferClientsComponent', () => { + let component: GroupTransferClientsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ GroupTransferClientsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(GroupTransferClientsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.ts b/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.ts new file mode 100644 index 000000000..5a59f06ba --- /dev/null +++ b/src/app/groups/groups-view/group-actions/group-transfer-clients/group-transfer-clients.component.ts @@ -0,0 +1,101 @@ +/** Angular Imports */ +import { Component, OnInit, AfterViewInit } from '@angular/core'; +import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; +import { Router, ActivatedRoute } from '@angular/router'; + +/** Custom Services */ +import { GroupsService } from 'app/groups/groups.service'; + +/** + * Group Transfer Clients component. + */ +@Component({ + selector: 'mifosx-group-transfer-clients', + templateUrl: './group-transfer-clients.component.html', + styleUrls: ['./group-transfer-clients.component.scss'] +}) +export class GroupTransferClientsComponent implements OnInit, AfterViewInit { + + /** Transfer Clients form. */ + transferClientsForm: FormGroup; + /** Group Data */ + groupData: any; + /** Group data. */ + groupsData: any = []; + /** Staff data. */ + staffData: any; + /** Group Members. */ + clientMembers: any[] = []; + + /** + * Retrieves the offices data from `resolve`. + * @param {FormBuilder} formBuilder Form Builder. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation + * @param {GroupsService} groupsService GroupsService. + */ + constructor(private formBuilder: FormBuilder, + private route: ActivatedRoute, + private router: Router, + private groupsService: GroupsService) { + this.route.data.subscribe((data: { groupActionData: any }) => { + this.groupData = data.groupActionData; + this.clientMembers = this.groupData.clientMembers; + }); + } + + ngOnInit() { + this.createTransferClientsForm(); + } + + /** + * Subscribes to Groups search filter: + */ + ngAfterViewInit() { + this.transferClientsForm.get('destinationGroupId').valueChanges.subscribe( (value: string) => { + if (value.length >= 2) { + this.groupsService.getFilteredGroups('name', 'ASC', value, this.groupData.officeId) + .subscribe( (data: any) => { + this.groupsData = data; + }); + } + }); + } + + /** + * Creates the transfer clients form. + */ + createTransferClientsForm() { + this.transferClientsForm = this.formBuilder.group({ + 'clients': ['', Validators.required], + 'inheritDestinationGroupLoanOfficer': [false], + 'destinationGroupId': ['', Validators.required] + }); + } + + /** + * Displays Group name in form control input. + * @param {any} group Group data. + * @returns {string} Group name if valid otherwise undefined. + */ + displayGroup(group: any): string | undefined { + return group ? group.name : undefined; + } + + /** + * Submits the group form and transfers the clients, + * if successful redirects to group. + */ + submit() { + const locale = 'en'; + const data = { + ...this.transferClientsForm.value, + destinationGroupId: this.transferClientsForm.get('destinationGroupId').value.id, + locale + }; + this.groupsService.executeGroupCommand(this.groupData.id, 'transferClients', data).subscribe(() => { + this.router.navigate(['../../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/groups/groups-view/groups-view.component.html b/src/app/groups/groups-view/groups-view.component.html index 17933d32d..344dbc1c2 100644 --- a/src/app/groups/groups-view/groups-view.component.html +++ b/src/app/groups/groups-view/groups-view.component.html @@ -61,7 +61,7 @@ Edit - diff --git a/src/app/groups/groups-view/groups-view.component.ts b/src/app/groups/groups-view/groups-view.component.ts index 12b64d245..910458741 100644 --- a/src/app/groups/groups-view/groups-view.component.ts +++ b/src/app/groups/groups-view/groups-view.component.ts @@ -51,6 +51,7 @@ export class GroupsViewComponent { case 'Attach Meeting': case 'Attendance': case 'Manage Members': + case 'Transfer Clients': this.router.navigate([`actions/${name}`], { relativeTo: this.route }); break; case 'Edit Meeting': diff --git a/src/app/groups/groups.module.ts b/src/app/groups/groups.module.ts index b91d5c3a0..97d8f9c04 100644 --- a/src/app/groups/groups.module.ts +++ b/src/app/groups/groups.module.ts @@ -31,6 +31,7 @@ import { GroupAttendanceComponent } from './groups-view/group-actions/group-atte import { ManageGroupMembersComponent } from './groups-view/group-actions/manage-group-members/manage-group-members.component'; import { EditGroupMeetingComponent } from './groups-view/group-actions/edit-group-meeting/edit-group-meeting.component'; import { EditGroupMeetingScheduleComponent } from './groups-view/group-actions/edit-group-meeting-schedule/edit-group-meeting-schedule.component'; +import { GroupTransferClientsComponent } from './groups-view/group-actions/group-transfer-clients/group-transfer-clients.component'; /** * Groups Module @@ -66,7 +67,8 @@ import { EditGroupMeetingScheduleComponent } from './groups-view/group-actions/e GroupAttendanceComponent, ManageGroupMembersComponent, EditGroupMeetingComponent, - EditGroupMeetingScheduleComponent + EditGroupMeetingScheduleComponent, + GroupTransferClientsComponent ], entryComponents: [ UnassignRoleDialogComponent, diff --git a/src/app/groups/groups.service.ts b/src/app/groups/groups.service.ts index 40a3c851a..ea3a1f2e3 100644 --- a/src/app/groups/groups.service.ts +++ b/src/app/groups/groups.service.ts @@ -19,6 +19,23 @@ 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} Groups. + */ + getFilteredGroups(orderBy: string, sortOrder: string, name: string, officeId?: any): Observable { + let httpParams = new HttpParams() + .set('name', name) + .set('sortOrder', sortOrder) + .set('orderBy', orderBy); + if (officeId) { + httpParams = httpParams.set('officeId', officeId); + } + 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. @@ -27,7 +44,7 @@ export class GroupsService { * @param {number} limit Number of entries within the page. * @returns {Observable} Groups. */ - getGroups(filterBy: any, orderBy: string, sortOrder: string, offset: number, limit: number): Observable { + getGroups(filterBy: any, orderBy: string, sortOrder: string, offset?: number, limit?: number): Observable { let httpParams = new HttpParams() .set('offset', offset.toString()) .set('limit', limit.toString())