Add support for bulk reading progress reset
This commit is contained in:
committed by
Aditya Chandel
parent
ec7846abf6
commit
77d68108ab
@@ -293,9 +293,9 @@
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="flex">
|
||||
@if (entityType$ | async; as entityType) {
|
||||
<div class="flex gap-6 pr-2">
|
||||
<div class="flex gap-2 md:gap-6 pr-2">
|
||||
@if (userData.permissions.canEditMetadata) {
|
||||
<p-menu #menu [model]="metadataMenuItems" [popup]="true" appendTo="body"/>
|
||||
<p-menu #menu [model]="metadataMenuItems" [popup]="true" appendTo="body" class="hidden"/>
|
||||
<p-button
|
||||
(click)="menu.toggle($event)"
|
||||
pTooltip="Metadata actions"
|
||||
@@ -343,10 +343,19 @@
|
||||
tooltipPosition="top">
|
||||
</p-button>
|
||||
}
|
||||
<p-menu #menuMore [model]="moreActionsMenuItems" [popup]="true" appendTo="body" class="hidden"/>
|
||||
<p-button
|
||||
(click)="menuMore.toggle($event)"
|
||||
pTooltip="More actions"
|
||||
tooltipPosition="top"
|
||||
outlined="true"
|
||||
severity="info"
|
||||
icon="pi pi-ellipsis-v">
|
||||
</p-button>
|
||||
</div>
|
||||
}
|
||||
<p-divider layout="vertical"></p-divider>
|
||||
<div class="flex gap-6 px-2">
|
||||
<div class="flex gap-2 md:gap-6 px-2">
|
||||
<p-button
|
||||
outlined="true"
|
||||
icon="pi pi-check-square"
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ export class BookCardComponent implements OnInit, OnDestroy {
|
||||
},
|
||||
},
|
||||
...this.getPermissionBasedMenuItems(),
|
||||
...this.moreMenuItems(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -258,6 +259,45 @@ export class BookCardComponent implements OnInit, OnDestroy {
|
||||
return items;
|
||||
}
|
||||
|
||||
private moreMenuItems(): MenuItem[] {
|
||||
const items: MenuItem[] = [];
|
||||
|
||||
if (this.hasEditMetadataPermission()) {
|
||||
items.push({
|
||||
label: 'More Actions',
|
||||
icon: 'pi pi-ellipsis-v',
|
||||
items: [
|
||||
{
|
||||
label: 'Reset Progress',
|
||||
icon: 'pi pi-undo',
|
||||
command: () => {
|
||||
this.bookService.resetProgress(this.book.id).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
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private openShelfDialog(): void {
|
||||
this.dialogService.open(ShelfAssignerComponent, {
|
||||
header: `Update Book's Shelves`,
|
||||
|
||||
Reference in New Issue
Block a user