feat: add center actions (close and delete) (#1093)

Fixes: #1092
This commit is contained in:
Muskan Khedia
2020-07-14 16:15:48 +05:30
committed by GitHub
parent 96f881e909
commit ffea1b5eaf
10 changed files with 192 additions and 5 deletions
@@ -8,6 +8,7 @@ import { ConfirmationDialogComponent } from 'app/shared/confirmation-dialog/conf
/** Custom Services */
import { CentersService } from '../centers.service';
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
/**
* Create Center View
@@ -57,11 +58,14 @@ export class CentersViewComponent implements OnInit {
switch (name) {
case 'Activate':
case 'Assign Staff':
case 'Close':
this.router.navigate([`actions/${name}`], { relativeTo: this.route });
break;
case 'Unassign Staff':
this.centersUnassignStaff();
break;
case 'Delete':
this.deleteCenter();
}
}
@@ -82,6 +86,22 @@ export class CentersViewComponent implements OnInit {
});
}
/**
* Deletes the center
*/
private deleteCenter() {
const deleteGroupDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `center with id: ${this.centerViewData.id}` }
});
deleteGroupDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.centersService.deleteCenter(this.centerViewData.id).subscribe(() => {
this.router.navigate(['/centers'], { relativeTo: this.route });
});
}
});
}
/**
* Refetches data for the component
* TODO: Replace by a custom reload component instead of hard-coded back-routing.