From: Bill Erickson Date: Thu, 15 Nov 2018 21:31:47 +0000 (-0500) Subject: Basket view uses search results page X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5546567385cf2117a92e595845c1ff47bc72129b;p=working%2FEvergreen.git Basket view uses search results page Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts index 253e3aacdd..5b3975049e 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts @@ -40,7 +40,8 @@ export class CatalogUrlService { } // These fields can be copied directly into place - ['format', 'sort', 'available', 'global', 'identQuery', 'identQueryType'] + ['format', 'sort', 'available', 'global', 'identQuery', + 'identQueryType', 'basket'] .forEach(field => { if (context[field]) { // Only propagate applied values to the URL. @@ -99,7 +100,8 @@ export class CatalogUrlService { context.reset(); // These fields can be copied directly into place - ['format', 'sort', 'available', 'global', 'identQuery', 'identQueryType'] + ['format', 'sort', 'available', 'global', 'identQuery', + 'identQueryType', 'basket'] .forEach(field => { const val = params.get(field); if (val !== null) { 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 2dc07c521f..c51340709c 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 @@ -9,6 +9,7 @@ import {NetService} from '@eg/core/net.service'; import {PcrudService} from '@eg/core/pcrud.service'; import {CatalogSearchContext, CatalogSearchState} from './search-context'; import {BibRecordService, BibRecordSummary} from './bib-record.service'; +import {BasketService} from './basket.service'; // CCVM's we care about in a catalog context // Don't fetch them all because there are a lot. @@ -46,7 +47,8 @@ export class CatalogService { private org: OrgService, private unapi: UnapiService, private pcrud: PcrudService, - private bibService: BibRecordService + private bibService: BibRecordService, + private basket: BasketService ) { this.onSearchComplete = new EventEmitter(); @@ -55,6 +57,33 @@ export class CatalogService { search(ctx: CatalogSearchContext): Promise { ctx.searchState = CatalogSearchState.SEARCHING; + if (ctx.basket) { + return this.basketSearch(ctx); + } else { + return this.querySearch(ctx); + } + } + + // "Search" the basket by loading the IDs and treating + // them like a standard query search results set. + basketSearch(ctx: CatalogSearchContext): Promise { + + return this.basket.getRecordIds().then(ids => { + + // Map our list of IDs into a search results object + // the search context can understand. + const result = { + count: ids.length, + ids: ids.map(id => [id]) + }; + + this.applyResultData(ctx, result); + ctx.searchState = CatalogSearchState.COMPLETE; + this.onSearchComplete.emit(ctx); + }); + } + + querySearch(ctx: CatalogSearchContext): Promise { const fullQuery = ctx.compileSearch(); console.debug(`search query: ${fullQuery}`); @@ -77,6 +106,7 @@ export class CatalogService { resolve(); }); }); + } applyResultData(ctx: CatalogSearchContext, result: any): void { 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 e4e64b2d0e..52ad4bc2d9 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 @@ -48,6 +48,7 @@ export class CatalogSearchContext { ccvmFilters: {[ccvmCode: string]: string[]}; facetFilters: FacetFilter[]; isStaff: boolean; + basket = false; // Result from most recent search. result: any = {}; @@ -118,10 +119,15 @@ export class CatalogSearchContext { this.result = {}; this.resultIds = []; this.searchState = CatalogSearchState.PENDING; + this.basket = false; } isSearchable(): boolean { + if (this.basket) { + return true; + } + if (this.identQuery && this.identQueryType) { return true; } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.html index 2485a39914..aa694774b8 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.html @@ -2,7 +2,9 @@
- + + shopping_basket ({{basketCount()}}) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts index d79d30915f..fd225f1476 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/basket-actions.component.ts @@ -30,7 +30,9 @@ export class BasketActionsComponent implements OnInit { switch(this.basketAction) { case 'view': - this.router.navigate(['/staff/catalog/basket']); + // This does not propagate search params -- unclear if needed. + this.router.navigate(['/staff/catalog/search'], + {queryParams: {basket: true}}); break; case 'clear': diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/basket/basket.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/basket/basket.component.html deleted file mode 100644 index 7a64033abf..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/catalog/basket/basket.component.html +++ /dev/null @@ -1,20 +0,0 @@ -
-
-

Basket View

-
-
-
- -
-
-
-
-
- - - - -
-
- diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/basket/basket.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/basket/basket.component.ts deleted file mode 100644 index 50affa8b67..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/catalog/basket/basket.component.ts +++ /dev/null @@ -1,60 +0,0 @@ -import {Component, OnInit, OnDestroy, Input} from '@angular/core'; -import {Router} from '@angular/router'; -import {Observable} from 'rxjs/Observable'; -import {Subscription} from 'rxjs/Subscription'; -import {BibRecordService} from '@eg/share/catalog/bib-record.service'; -import {CatalogService} from '@eg/share/catalog/catalog.service'; -import {StaffCatalogService} from '../catalog.service'; -import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context'; -import {BasketService} from '@eg/share/catalog/basket.service'; - -@Component({ - selector: 'eg-catalog-basket', - templateUrl: 'basket.component.html' -}) -export class BasketComponent implements OnInit, OnDestroy { - - searchContext: CatalogSearchContext; - - constructor( - private router: Router, - private bib: BibRecordService, - private cat: CatalogService, - private staffCat: StaffCatalogService, - private basket: BasketService - ) {} - - ngOnInit() { - this.searchContext = this.staffCat.searchContext; - - this.basket.getRecordIds().then(ids => { - - // Bypass the standard catalog search by providing a - // search result object of our own. - // Map our list of IDs into a search results object - // the search context can understand. - const result = { - count: ids.length, - ids: ids.map(id => [id]) - }; - - this.searchContext.reset(); - this.cat.applyResultData(this.searchContext, result); - this.cat.fetchBibSummaries(this.searchContext) - .then(ok => this.fleshSearchResults()); - - }); - } - - ngOnDestroy() { - } - - fleshSearchResults(): void { - const records = this.searchContext.result.records; - if (!records || records.length === 0) { return; } - // Flesh the creator / editor fields with the user object. - this.bib.fleshBibUsers(records.map(r => r.record)); - } -} - - diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts index 172a82993d..e490da2b80 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts @@ -15,7 +15,6 @@ import {RecordPaginationComponent} from './record/pagination.component'; import {RecordActionsComponent} from './record/actions.component'; import {HoldingsService} from '@eg/staff/share/holdings.service'; import {BasketActionsComponent} from './basket-actions.component'; -import {BasketComponent} from './basket/basket.component'; @NgModule({ declarations: [ @@ -29,8 +28,7 @@ import {BasketComponent} from './basket/basket.component'; ResultPaginationComponent, RecordPaginationComponent, RecordActionsComponent, - BasketActionsComponent, - BasketComponent + BasketActionsComponent ], imports: [ StaffCommonModule, diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/routing.module.ts index d92bcf60a7..0e3c96fd00 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/routing.module.ts @@ -4,7 +4,6 @@ import {CatalogComponent} from './catalog.component'; import {ResultsComponent} from './result/results.component'; import {RecordComponent} from './record/record.component'; import {CatalogResolver} from './resolver.service'; -import {BasketComponent} from './basket/basket.component'; const routes: Routes = [{ path: '', @@ -14,9 +13,6 @@ const routes: Routes = [{ path: 'search', component: ResultsComponent }, { - path: 'basket', - component: BasketComponent - }, { path: 'record/:id', component: RecordComponent }, {