book drop bulk select will auto-select if there is only one option

This commit is contained in:
Ionuț Staicu
2025-08-12 18:10:45 +03:00
parent 3ebc617196
commit 79ccc436d1
@@ -75,7 +75,8 @@ export class BookdropFileReviewComponent implements OnInit {
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
uploadPattern = '';
defaultLibraryId: string | null = null;
_defaultLibraryId: string | null = null;
defaultPathId: string | null = null;
libraries: Library[] = [];
bookdropFileUis: BookdropFileUI[] = [];
@@ -108,6 +109,20 @@ export class BookdropFileReviewComponent implements OnInit {
});
}
get defaultLibraryId() {
return this._defaultLibraryId;
}
set defaultLibraryId(value: string | null) {
this._defaultLibraryId = value;
const selected = this.libraries.find((lib) => lib?.id && String(lib.id) === value)
if (selected && selected.paths.length ===1) {
this.defaultPathId = String(selected.paths[0].id)
}
}
get libraryOptions() {
if (!this.libraries) return [];
return this.libraries.map(lib => ({label: lib.name, value: String(lib.id ?? '')}));