diff --git a/frontend/angular-seshat/src/app/library/search-box/search-box.component.html b/frontend/angular-seshat/src/app/library/search-box/search-box.component.html index 95de64c..950a113 100644 --- a/frontend/angular-seshat/src/app/library/search-box/search-box.component.html +++ b/frontend/angular-seshat/src/app/library/search-box/search-box.component.html @@ -24,7 +24,8 @@ [class.collapsed]="!filtersEnabled.value">
- @@ -42,7 +44,8 @@
-
- - ISBN +
diff --git a/frontend/angular-seshat/src/app/library/search-box/search-box.component.ts b/frontend/angular-seshat/src/app/library/search-box/search-box.component.ts index c486c5a..8c16384 100644 --- a/frontend/angular-seshat/src/app/library/search-box/search-box.component.ts +++ b/frontend/angular-seshat/src/app/library/search-box/search-box.component.ts @@ -1,4 +1,4 @@ -import { Component, inject, NgZone, OnDestroy, output } from '@angular/core'; +import { AfterViewInit, Component, ElementRef, inject, NgZone, OnDestroy, output, ViewChild } from '@angular/core'; import { FormControl, ReactiveFormsModule } from '@angular/forms'; import { SearchContextDto } from '../../shared/dto/search-context.dto'; import { filter, Subscription } from 'rxjs'; @@ -15,10 +15,15 @@ import { CommonModule } from '@angular/common'; templateUrl: './search-box.component.html', styleUrl: './search-box.component.css' }) -export class SearchBoxComponent implements OnDestroy { +export class SearchBoxComponent implements AfterViewInit, OnDestroy { private readonly _subscriptions: Subscription[] = []; private readonly _zone = inject(NgZone); + @ViewChild('languageSelect') private readonly languageRef: ElementRef = {} as ElementRef; + @ViewChild('orderBySelect') private readonly orderByRef: ElementRef = {} as ElementRef; + @ViewChild('resultsSizeSelect') private readonly resultsSizeRef: ElementRef = {} as ElementRef; + @ViewChild('isbnInput') private readonly isbnRef: ElementRef = {} as ElementRef; + config = inject(ConfigService).config; filtersEnabled = new FormControl(false); search = new FormControl(''); @@ -43,6 +48,21 @@ export class SearchBoxComponent implements OnDestroy { }); } + ngAfterViewInit() { + if (this.languageRef) + this.updateFilters('langRestrict', this.languageRef.nativeElement); + if (this.orderByRef) + this.updateFilters('orderBy', this.orderByRef.nativeElement); + if (this.resultsSizeRef) + this.updateFilters('maxResults', this.resultsSizeRef.nativeElement); + if (this.isbnRef) + this.updateFilters('isbn', this.isbnRef.nativeElement); + } + + ngOnDestroy(): void { + this._subscriptions.forEach(s => s.unsubscribe()); + } + get provider() { switch (this.config.providers.default) { case 'google': return this.config.providers.google; @@ -58,8 +78,4 @@ export class SearchBoxComponent implements OnDestroy { } this.filtersOutput.emit(this.filters); } - - ngOnDestroy(): void { - this._subscriptions.forEach(s => s.unsubscribe()); - } }