feat: group actions (delete) (#1035)

Fixes: #1034
This commit is contained in:
Karan Takalkar
2020-07-08 17:38:49 +05:30
committed by GitHub
parent f0a2978db5
commit 205ce6bdc2
3 changed files with 29 additions and 1 deletions
@@ -86,7 +86,7 @@
<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'" (click)="doAction('Close')">Close</button>
<button mat-menu-item *mifosxHasPermission="'DELETE_GROUP'">Delete</button>
<button mat-menu-item *mifosxHasPermission="'DELETE_GROUP'" (click)="doAction('Delete')">Delete</button>
</mat-menu>
</mat-card-actions>
@@ -5,6 +5,7 @@ import { MatDialog } from '@angular/material';
/** Custom Dialogs */
import { UnassignStaffDialogComponent } from './custom-dialogs/unassign-staff-dialog/unassign-staff-dialog.component';
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
/** Custom Services */
import { GroupsService } from '../groups.service';
@@ -52,6 +53,9 @@ export class GroupsViewComponent {
case 'Unassign Staff':
this.unassignStaff();
break;
case 'Delete':
this.deleteGroup();
break;
}
}
@@ -80,4 +84,20 @@ export class GroupsViewComponent {
});
}
/**
* Deletes the group
*/
private deleteGroup() {
const deleteGroupDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `group with id: ${this.groupViewData.id}` }
});
deleteGroupDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.groupsService.deleteGroup(this.groupViewData.id).subscribe(() => {
this.router.navigate(['/groups'], { relativeTo: this.route });
});
}
});
}
}
+8
View File
@@ -52,6 +52,14 @@ export class GroupsService {
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.
* @returns {Observable<any>} Group data.