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
@@ -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 });
});
}
});
}
}