From 471168013903ee541368d22322c5ffab7f3208d6 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 7 Dec 2018 12:31:05 -0500 Subject: [PATCH] LP#1806087 Catalog tabbed layout Signed-off-by: Bill Erickson --- .../eg2/src/app/share/catalog/catalog.service.ts | 19 ++ .../eg2/src/app/share/catalog/search-context.ts | 1 + .../app/staff/catalog/search-form.component.css | 10 + .../app/staff/catalog/search-form.component.html | 372 ++++++++++----------- .../src/app/staff/catalog/search-form.component.ts | 40 +-- 5 files changed, 234 insertions(+), 208 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts index 30d9a09dfd..ccf928441f 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts @@ -63,11 +63,30 @@ export class CatalogService { return this.basketSearch(ctx); } else if (ctx.marcValue[0] !== '') { return this.marcSearch(ctx); + } else if (ctx.identQueryType === 'item_barcode') { + return this.barcodeSearch(ctx); } else { return this.querySearch(ctx); } } + barcodeSearch(ctx: CatalogSearchContext): Promise { + return this.net.request( + 'open-ils.search', + 'open-ils.search.multi_home.bib_ids.by_barcode', + ctx.identQuery + ).toPromise().then(ids => { + const result = { + count: ids.length, + ids: ids.map(id => [id]) + }; + + this.applyResultData(ctx, result); + ctx.searchState = CatalogSearchState.COMPLETE; + this.onSearchComplete.emit(ctx); + }); + } + // "Search" the basket by loading the IDs and treating // them like a standard query search results set. basketSearch(ctx: CatalogSearchContext): Promise { diff --git a/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts b/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts index 9dd448fd3f..b1b7e7a6a9 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts @@ -55,6 +55,7 @@ export class CatalogSearchContext { marcTag: string[]; marcSubfield: string[]; marcValue: string[]; + isMetarecord: boolean; // TODO // Result from most recent search. result: any = {}; diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.css b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.css index 6201dff923..f41908a5f6 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.css +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.css @@ -14,3 +14,13 @@ select.form-control:not([size]):not([multiple]) { #staffcat-search-form { border-bottom: 2px dashed rgba(0,0,0,.225); } + +#staffcat-search-form .tab-content { + border: 3px; +} + +.tab-content { + padding: 5px; + margin-top: 25px; + font-weight: bold; +} diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html index b0db7a3dc4..01bb3bdbbe 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html @@ -1,168 +1,132 @@ -
-
-
-
-
- -
-
- -
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- - -
-
-
-
- - - - - -
-
-
- -
-
-
- - -
-
- -
-
-
- -
-
-
-
- -
-
-
- -
-
-
- -
-
- -
+
+
- + -
-
+
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ + + +
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
- - + + - - +
-
+
@@ -247,17 +209,17 @@ TODO focus search input - + + (click)="searchByForm()" i18n>Search
@@ -265,20 +227,24 @@ TODO focus search input -
+
- + - + + [(ngModel)]="searchContext.marcValue[idx]" + (keyup.enter)="searchByForm()"/> + (click)="searchByForm()" i18n>Submit
@@ -297,5 +263,35 @@ TODO focus search input
+
+
+
+
+ + + + + +
+
+
+
+
+ +
+
+
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts index 3d8a1ad66d..fbe92b8301 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts @@ -17,7 +17,7 @@ export class SearchFormComponent implements OnInit, AfterViewInit { searchContext: CatalogSearchContext; ccvmMap: {[ccvm: string]: IdlObject[]} = {}; cmfMap: {[cmf: string]: IdlObject} = {}; - showAdvancedSearch = false; + showSearchFilters = false; copyLocations: IdlObject[]; searchTab: string; //@ViewChild('searchTabs') searchTabs: NgbTabset; @@ -30,7 +30,7 @@ export class SearchFormComponent implements OnInit, AfterViewInit { private staffCat: StaffCatalogService ) { this.copyLocations = []; - this.searchTab = 'filters'; + this.searchTab = 'term'; } ngOnInit() { @@ -40,7 +40,7 @@ export class SearchFormComponent implements OnInit, AfterViewInit { // Start with advanced search options open // if any filters are active. - this.showAdvancedSearch = this.hasAdvancedOptions(); + this.showSearchFilters = this.filtersActive(); } ngAfterViewInit() { @@ -54,7 +54,7 @@ export class SearchFormComponent implements OnInit, AfterViewInit { if (st === 'marc' || st === 'ident') { this.searchTab = st; } else { - this.searchTab = 'filters'; + this.searchTab = 'term'; } }); @@ -87,20 +87,18 @@ export class SearchFormComponent implements OnInit, AfterViewInit { * Display the advanced/extended search options when asked to * or if any advanced options are selected. */ - showAdvanced(): boolean { - return this.showAdvancedSearch; + showFilters(): boolean { + return this.showSearchFilters; } - toggleAdvancedSearch() { - this.showAdvancedSearch = !this.showAdvancedSearch; + toggleFilters() { + this.showSearchFilters = !this.showSearchFilters; this.refreshCopyLocations(); } - hasAdvancedOptions(): boolean { + filtersActive(): boolean { if (this.searchContext.copyLocations[0] !== '') { return true; } - if (this.searchContext.identQuery) { return true; } - if (this.searchContext.marcValue[0] !== '') { return true; } // ccvm filters may be present without any filters applied. // e.g. if filters were applied then removed. @@ -120,7 +118,7 @@ export class SearchFormComponent implements OnInit, AfterViewInit { } refreshCopyLocations() { - if (!this.showAdvanced()) { return; } + if (!this.showFilters()) { return; } // TODO: is this how we avoid displaying too many locations? const org = this.searchContext.searchOrg; @@ -164,15 +162,20 @@ export class SearchFormComponent implements OnInit, AfterViewInit { this.searchContext.marcValue.splice(index, 1); } - formEnter(source) { + searchByForm(): void { + // Starting a new search this.searchContext.pager.offset = 0; - // Form searches override basket displays. + // Trim the search context to necessary data only depending + // on which tab the user is on, i.e. which type of search + // the user is requesting. + + // A form search overrides an existing basket display request this.searchContext.basket = null; - switch (source) { + switch (this.searchTab) { - case 'query': // main search form query input + case 'term': // main search form query input // Be sure a previous ident search does not take precedence // over the new term query submitted via Enter within @@ -198,7 +201,7 @@ export class SearchFormComponent implements OnInit, AfterViewInit { break; } - this.searchByForm(); + this.staffCat.search(); } // https://stackoverflow.com/questions/42322968/angular2-dynamic-input-field-lose-focus-when-input-changes @@ -206,9 +209,6 @@ export class SearchFormComponent implements OnInit, AfterViewInit { return index; } - searchByForm(): void { - this.staffCat.search(); - } searchIsActive(): boolean { return this.searchContext.searchState === CatalogSearchState.SEARCHING; -- 2.11.0