Add support for bulk reading progress reset

This commit is contained in:
aditya.chandel
2025-07-14 09:19:22 -06:00
committed by Aditya Chandel
parent ec7846abf6
commit 77d68108ab
6 changed files with 133 additions and 25 deletions
@@ -149,6 +149,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
lastAppliedSort: SortOption | null = null;
private settingFiltersFromUrl = false;
protected metadataMenuItems: MenuItem[] | undefined;
protected moreActionsMenuItems: MenuItem[] | undefined;
currentBooks: Book[] = [];
lastSelectedIndex: number | null = null;
showFilter: boolean = false;
@@ -226,8 +227,28 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
command: () => this.multiBookEditMetadata()
}
];
this.moreActionsMenuItems = [
{
label: 'Reset Progress',
icon: 'pi pi-undo',
command: () => {
this.confirmationService.confirm({
message: 'Are you sure you want to reset progress for selected books?',
header: 'Confirm Reset',
icon: 'pi pi-exclamation-triangle',
acceptLabel: 'Yes',
rejectLabel: 'No',
accept: () => {
this.resetProgress();
}
});
}
}
];
}
ngAfterViewInit() {
combineLatest({
@@ -688,4 +709,26 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
moveFiles() {
this.dialogHelperService.openFileMoverDialog(this.selectedBooks);
}
resetProgress() {
const bookIds = Array.from(this.selectedBooks);
this.bookService.resetProgress(bookIds).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Progress Reset',
detail: 'Reading progress has been reset.',
life: 1500
});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Failed',
detail: 'Could not reset progress.',
life: 1500
});
}
});
}
}