Confirm dialog can now optionally use warn colors (used for deletion or breaking changes)

Category re-ordering is fixed

Category deletion in settings is now functional
This commit is contained in:
Isaac Abadi
2020-10-15 17:00:48 -04:00
parent 6f089491a5
commit d4e5082039
5 changed files with 37 additions and 6 deletions

View File

@@ -82,7 +82,11 @@ export class SettingsComponent implements OnInit {
dropCategory(event: CdkDragDrop<string[]>) {
moveItemInArray(this.postsService.categories, event.previousIndex, event.currentIndex);
this.postsService.updateCategories(this.postsService.categories);
this.postsService.updateCategories(this.postsService.categories).subscribe(res => {
}, err => {
this.postsService.openSnackBar('Failed to update categories!');
});
}
openAddCategoryDialog() {
@@ -113,6 +117,29 @@ export class SettingsComponent implements OnInit {
});
}
deleteCategory(category) {
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
data: {
dialogTitle: 'Delete category',
dialogText: `Would you like to delete ${category['name']}?`,
submitText: 'Delete',
warnSubmitColor: true
}
});
dialogRef.afterClosed().subscribe(confirmed => {
if (confirmed) {
this.postsService.deleteCategory(category['uid']).subscribe(res => {
if (res['success']) {
this.postsService.openSnackBar(`Successfully deleted ${category['name']}!`);
this.postsService.reloadCategories();
}
}, err => {
this.postsService.openSnackBar(`Failed to delete ${category['name']}!`);
});
}
});
}
openEditCategoryDialog(category) {
this.dialog.open(EditCategoryDialogComponent, {
data: {
@@ -206,7 +233,8 @@ export class SettingsComponent implements OnInit {
dialogTitle: 'Kill downloads',
dialogText: 'Are you sure you want to kill all downloads? Any subscription and non-subscription downloads will end immediately, though this operation may take a minute or so to complete.',
submitText: 'Kill all downloads',
doneEmitter: done
doneEmitter: done,
warnSubmitColor: true
}
});
done.subscribe(confirmed => {