- Refactor to remove BookMetadataBI
- Use inject everywhere instead of constructor injection
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {Component, inject, OnInit, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {MenuItem, MessageService} from 'primeng/api';
|
||||
import {LibraryService} from '../../service/library.service';
|
||||
@@ -81,16 +81,14 @@ export class BookBrowserComponent implements OnInit {
|
||||
|
||||
@ViewChild(BookTableComponent) bookTableComponent!: BookTableComponent;
|
||||
|
||||
constructor(
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private messageService: MessageService,
|
||||
private libraryService: LibraryService,
|
||||
private bookService: BookService,
|
||||
private shelfService: ShelfService,
|
||||
private dialogService: DialogService,
|
||||
private sortService: SortService,
|
||||
private libraryShelfMenuService: LibraryShelfMenuService) {
|
||||
}
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
private messageService = inject(MessageService);
|
||||
private libraryService = inject(LibraryService);
|
||||
private bookService = inject(BookService);
|
||||
private shelfService = inject(ShelfService);
|
||||
private dialogService = inject(DialogService);
|
||||
private sortService = inject(SortService);
|
||||
private libraryShelfMenuService = inject(LibraryShelfMenuService);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.sortOptions = SortService.generateSortOptions();
|
||||
@@ -262,7 +260,9 @@ export class BookBrowserComponent implements OnInit {
|
||||
deselectAllBooks(): void {
|
||||
this.selectedBooks.clear();
|
||||
this.isDrawerVisible = false;
|
||||
this.bookTableComponent.clearSelectedBooks();
|
||||
if(this.bookTableComponent) {
|
||||
this.bookTableComponent.clearSelectedBooks();
|
||||
}
|
||||
}
|
||||
|
||||
viewChanged() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {Component, inject, Input, OnInit} from '@angular/core';
|
||||
import {Book} from '../../../model/book.model';
|
||||
import {Button} from 'primeng/button';
|
||||
import {MenuModule} from 'primeng/menu';
|
||||
@@ -26,9 +26,9 @@ export class BookCardComponent implements OnInit {
|
||||
items: MenuItem[] | undefined;
|
||||
isHovered: boolean = false;
|
||||
|
||||
constructor(private bookService: BookService, private dialogService: DialogService,
|
||||
private metadataDialogService: MetadataDialogService) {
|
||||
}
|
||||
private bookService = inject(BookService);
|
||||
private dialogService = inject(DialogService);
|
||||
private metadataDialogService = inject(MetadataDialogService);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.initMenu();
|
||||
@@ -39,7 +39,7 @@ export class BookCardComponent implements OnInit {
|
||||
}
|
||||
|
||||
readBook(book: Book): void {
|
||||
this.bookService.readBook(book);
|
||||
this.bookService.readBook(book.id);
|
||||
}
|
||||
|
||||
toggleSelection(selected: boolean): void {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, EventEmitter, Input, OnChanges, Output} from '@angular/core';
|
||||
import {Component, EventEmitter, inject, Input, OnChanges, Output} from '@angular/core';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {BookService} from '../../../service/book.service';
|
||||
@@ -30,8 +30,9 @@ export class BookTableComponent implements OnChanges {
|
||||
@Input() books: Book[] = [];
|
||||
@Input() sortOption: SortOption | null = null;
|
||||
|
||||
constructor(private bookService: BookService, private metadataDialogService: MetadataDialogService) {
|
||||
}
|
||||
private bookService = inject(BookService);
|
||||
private metadataDialogService = inject(MetadataDialogService);
|
||||
|
||||
|
||||
// Hack to set virtual-scroller height
|
||||
ngOnChanges() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Subject, Subscription} from 'rxjs';
|
||||
import {catchError, debounceTime, distinctUntilChanged, switchMap} from 'rxjs/operators';
|
||||
import {Book} from '../../model/book.model';
|
||||
@@ -11,6 +11,7 @@ import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {Button} from 'primeng/button';
|
||||
import {NgForOf, NgIf} from '@angular/common';
|
||||
import {MetadataDialogService} from '../../../metadata/service/metadata-dialog.service';
|
||||
import {LibraryShelfMenuService} from '../../service/library-shelf-menu.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-searcher',
|
||||
@@ -31,8 +32,9 @@ export class BookSearcherComponent implements OnInit, OnDestroy {
|
||||
#searchSubject = new Subject<string>();
|
||||
#subscription!: Subscription;
|
||||
|
||||
constructor(private bookService: BookService, private metadataDialogService: MetadataDialogService) {
|
||||
}
|
||||
private bookService = inject(BookService);
|
||||
private metadataDialogService = inject(MetadataDialogService);
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
this.initializeSearch();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, ViewChild} from '@angular/core';
|
||||
import {Component, inject, ViewChild} from '@angular/core';
|
||||
import {DialogService, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {DirectoryPickerComponent} from '../../../utilities/component/directory-picker/directory-picker.component';
|
||||
import {MessageService} from 'primeng/api';
|
||||
@@ -12,6 +12,7 @@ import {Step, StepList, StepPanel, StepPanels, Stepper} from 'primeng/stepper';
|
||||
import {NgIf} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {BookService} from '../../service/book.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-library-creator',
|
||||
@@ -41,13 +42,12 @@ export class LibraryCreatorComponent {
|
||||
ref: DynamicDialogRef | undefined;
|
||||
selectedIcon: string | null = null;
|
||||
|
||||
constructor(
|
||||
private dialogService: DialogService,
|
||||
private dynamicDialogRef: DynamicDialogRef,
|
||||
private libraryService: LibraryService,
|
||||
private messageService: MessageService,
|
||||
private router: Router) {
|
||||
}
|
||||
private dialogService = inject(DialogService);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private libraryService = inject(LibraryService);
|
||||
private messageService = inject(MessageService);
|
||||
private router = inject(Router);
|
||||
|
||||
|
||||
show() {
|
||||
this.ref = this.dialogService.open(DirectoryPickerComponent, {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {Component, inject, OnInit, ViewChild} from '@angular/core';
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {Book} from '../../model/book.model';
|
||||
import {MessageService, PrimeTemplate} from 'primeng/api';
|
||||
@@ -16,6 +16,7 @@ import {Checkbox} from 'primeng/checkbox';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Dialog} from 'primeng/dialog';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf-assigner',
|
||||
@@ -37,30 +38,24 @@ import {InputText} from 'primeng/inputtext';
|
||||
styleUrls: ['./shelf-assigner.component.scss']
|
||||
})
|
||||
export class ShelfAssignerComponent implements OnInit {
|
||||
shelfState$: Observable<ShelfState>;
|
||||
book: Book;
|
||||
|
||||
private shelfService = inject(ShelfService);
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||
private messageService = inject(MessageService);
|
||||
private bookService = inject(BookService);
|
||||
|
||||
shelfState$: Observable<ShelfState> = this.shelfService.shelfState$;
|
||||
book: Book = this.dynamicDialogConfig.data.book;
|
||||
selectedShelves: Shelf[] = [];
|
||||
displayShelfDialog: boolean = false;
|
||||
shelfName: string = '';
|
||||
bookIds = new Set<number>();
|
||||
isMultiBooks: boolean = false;
|
||||
bookIds: Set<number> = this.dynamicDialogConfig.data.bookIds;
|
||||
isMultiBooks: boolean = this.dynamicDialogConfig.data.isMultiBooks;
|
||||
selectedIcon: string | null = null;
|
||||
|
||||
@ViewChild(IconPickerComponent) iconPicker: IconPickerComponent | undefined;
|
||||
|
||||
constructor(
|
||||
private shelfService: ShelfService,
|
||||
private dynamicDialogConfig: DynamicDialogConfig,
|
||||
private dynamicDialogRef: DynamicDialogRef,
|
||||
private messageService: MessageService,
|
||||
private bookService: BookService
|
||||
) {
|
||||
this.shelfState$ = this.shelfService.shelfState$;
|
||||
this.book = this.dynamicDialogConfig.data.book;
|
||||
this.bookIds = this.dynamicDialogConfig.data.bookIds;
|
||||
this.isMultiBooks = this.dynamicDialogConfig.data.isMultiBooks;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
if (!this.isMultiBooks && this.book.shelves) {
|
||||
this.shelfState$.pipe(
|
||||
|
||||
Reference in New Issue
Block a user