Fix library creation from dashboard
This commit is contained in:
@@ -42,14 +42,16 @@ export class LibraryCreatorComponent implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.mode = this.dynamicDialogConfig.data.mode;
|
const data = this.dynamicDialogConfig?.data;
|
||||||
if (this.mode === 'edit') {
|
if (data?.mode === 'edit') {
|
||||||
this.library = this.libraryService.findLibraryById(this.dynamicDialogConfig.data.libraryId);
|
this.mode = data.mode;
|
||||||
|
this.library = this.libraryService.findLibraryById(data.libraryId);
|
||||||
if (this.library) {
|
if (this.library) {
|
||||||
this.chosenLibraryName = this.library.name;
|
const { name, icon, paths } = this.library;
|
||||||
this.editModeLibraryName = this.library.name;
|
this.chosenLibraryName = name;
|
||||||
this.selectedIcon = 'pi pi-' + this.library.icon;
|
this.editModeLibraryName = name;
|
||||||
this.folders = this.library.paths.map(path => path.path);
|
this.selectedIcon = `pi pi-${icon}`;
|
||||||
|
this.folders = paths.map(path => path.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export class MainDashboardComponent implements OnInit {
|
|||||||
ref: DynamicDialogRef | undefined;
|
ref: DynamicDialogRef | undefined;
|
||||||
|
|
||||||
private bookService = inject(BookService);
|
private bookService = inject(BookService);
|
||||||
|
private dialogService = inject(DialogService);
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.bookService.loadBooks();
|
this.bookService.loadBooks();
|
||||||
@@ -35,7 +36,7 @@ export class MainDashboardComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
|
|
||||||
createNewLibrary() {
|
createNewLibrary() {
|
||||||
this.ref = inject(DialogService).open(LibraryCreatorComponent, {
|
this.ref = this.dialogService.open(LibraryCreatorComponent, {
|
||||||
header: 'Create New Library',
|
header: 'Create New Library',
|
||||||
modal: true,
|
modal: true,
|
||||||
closable: true,
|
closable: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user