From 484da7936d8780fe35d6cc28d56d2ca8eb562ecb Mon Sep 17 00:00:00 2001 From: ACX <8075870+acx10@users.noreply.github.com> Date: Fri, 6 Mar 2026 17:29:32 -0700 Subject: [PATCH] Allow importing and exporting magic shelf JSON from the UI (#3183) (#3210) --- .../service/library-shelf-menu.service.ts | 11 +++++ .../component/magic-shelf-component.html | 20 +++++++++ .../component/magic-shelf-component.scss | 23 ++++++++++ .../component/magic-shelf-component.ts | 43 ++++++++++++++++++- booklore-ui/src/i18n/en/book.json | 2 + booklore-ui/src/i18n/en/magic-shelf.json | 9 ++++ booklore-ui/src/i18n/es/book.json | 2 + booklore-ui/src/i18n/es/magic-shelf.json | 9 ++++ 8 files changed, 117 insertions(+), 2 deletions(-) diff --git a/booklore-ui/src/app/features/book/service/library-shelf-menu.service.ts b/booklore-ui/src/app/features/book/service/library-shelf-menu.service.ts index a737a310d..6b0eb9a62 100644 --- a/booklore-ui/src/app/features/book/service/library-shelf-menu.service.ts +++ b/booklore-ui/src/app/features/book/service/library-shelf-menu.service.ts @@ -244,6 +244,17 @@ export class LibraryShelfMenuService { this.dialogLauncherService.openMagicShelfEditDialog((entity?.id as number)); } }, + { + label: this.t.translate('book.shelfMenuService.magicShelf.exportJson'), + icon: 'pi pi-copy', + command: () => { + if (entity?.filterJson) { + navigator.clipboard.writeText(entity.filterJson).then(() => { + this.messageService.add({severity: 'success', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfMenuService.toast.magicShelfJsonCopiedDetail')}); + }); + } + } + }, { separator: true }, diff --git a/booklore-ui/src/app/features/magic-shelf/component/magic-shelf-component.html b/booklore-ui/src/app/features/magic-shelf/component/magic-shelf-component.html index 08eea088c..309355cb6 100644 --- a/booklore-ui/src/app/features/magic-shelf/component/magic-shelf-component.html +++ b/booklore-ui/src/app/features/magic-shelf/component/magic-shelf-component.html @@ -72,6 +72,16 @@ } + @if (showImportPanel) { +
+ +
+ + +
+
+ } +
@@ -79,6 +89,16 @@