Fix: Deselect items when they are removed from current view in book browser (#2093)
Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
+23
-15
@@ -256,15 +256,15 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
this.userService.userState$.pipe(filter(u => !!u?.user && u.loaded))
|
this.userService.userState$.pipe(filter(u => !!u?.user && u.loaded))
|
||||||
.subscribe(userState => {
|
.subscribe(userState => {
|
||||||
this.metadataMenuItems = this.bookMenuService.getMetadataMenuItems(
|
this.metadataMenuItems = this.bookMenuService.getMetadataMenuItems(
|
||||||
() => this.autoFetchMetadata(),
|
() => this.autoFetchMetadata(),
|
||||||
() => this.fetchMetadata(),
|
() => this.fetchMetadata(),
|
||||||
() => this.bulkEditMetadata(),
|
() => this.bulkEditMetadata(),
|
||||||
() => this.multiBookEditMetadata(),
|
() => this.multiBookEditMetadata(),
|
||||||
() => this.regenerateCoversForSelected(),
|
() => this.regenerateCoversForSelected(),
|
||||||
userState.user
|
userState.user
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.bulkReadActionsMenuItems = this.bookMenuService.getBulkReadActionsMenu(this.selectedBooks, this.user());
|
this.bulkReadActionsMenuItems = this.bookMenuService.getBulkReadActionsMenu(this.selectedBooks, this.user());
|
||||||
|
|
||||||
@@ -476,18 +476,18 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
if (selected) {
|
if (selected) {
|
||||||
if (book.seriesBooks) {
|
if (book.seriesBooks) {
|
||||||
//it is a series
|
//it is a series
|
||||||
this.selectedBooks = new Set([...this.selectedBooks, ...book.seriesBooks.map(book=>book.id)]);
|
this.selectedBooks = new Set([...this.selectedBooks, ...book.seriesBooks.map(book => book.id)]);
|
||||||
} else {
|
} else {
|
||||||
this.selectedBooks.add(book.id);
|
this.selectedBooks.add(book.id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (book.seriesBooks) {
|
if (book.seriesBooks) {
|
||||||
//it is a series
|
//it is a series
|
||||||
book.seriesBooks.forEach(book =>{
|
book.seriesBooks.forEach(book => {
|
||||||
this.selectedBooks.delete(book.id);
|
this.selectedBooks.delete(book.id);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.selectedBooks.delete(book.id);
|
this.selectedBooks.delete(book.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,7 +557,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
this.selectedBooks.clear();
|
this.selectedBooks.clear();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
reject: () => {}
|
reject: () => {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,6 +657,13 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
openShelfAssigner(): void {
|
openShelfAssigner(): void {
|
||||||
this.dynamicDialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks);
|
this.dynamicDialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks);
|
||||||
|
if (this.dynamicDialogRef) {
|
||||||
|
this.dynamicDialogRef.onClose.subscribe(result => {
|
||||||
|
if (result.assigned) {
|
||||||
|
this.selectedBooks.clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lockUnlockMetadata(): void {
|
lockUnlockMetadata(): void {
|
||||||
@@ -709,7 +717,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
|||||||
life: 3000
|
life: 3000
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -74,11 +74,11 @@ export class ShelfAssignerComponent implements OnInit {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book shelves updated'});
|
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book shelves updated'});
|
||||||
this.dynamicDialogRef.close();
|
this.dynamicDialogRef.close({assigned: true});
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book shelves'});
|
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to update book shelves'});
|
||||||
this.dynamicDialogRef.close();
|
this.dynamicDialogRef.close({assigned: false});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ export class ShelfAssignerComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
closeDialog(): void {
|
closeDialog(): void {
|
||||||
this.dynamicDialogRef.close();
|
this.dynamicDialogRef.close({assigned: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
isShelfSelected(shelf: Shelf): boolean {
|
isShelfSelected(shelf: Shelf): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user