}
// 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.
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) {
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.
private org: OrgService,
private unapi: UnapiService,
private pcrud: PcrudService,
- private bibService: BibRecordService
+ private bibService: BibRecordService,
+ private basket: BasketService
) {
this.onSearchComplete = new EventEmitter<CatalogSearchContext>();
search(ctx: CatalogSearchContext): Promise<void> {
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<void> {
+
+ 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<void> {
const fullQuery = ctx.compileSearch();
console.debug(`search query: ${fullQuery}`);
resolve();
});
});
+
}
applyResultData(ctx: CatalogSearchContext, result: any): void {
ccvmFilters: {[ccvmCode: string]: string[]};
facetFilters: FacetFilter[];
isStaff: boolean;
+ basket = false;
// Result from most recent search.
result: any = {};
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;
}
<div class="row">
<div class="col-lg-4 pr-1">
<div class="float-right">
- <a routerLink="/staff/catalog/basket" class="label-with-material-icon">
+ <!-- note basket view link does not propagate search params -->
+ <a routerLink="/staff/catalog/search" [queryParams]="{basket: true}"
+ class="label-with-material-icon">
<span class="material-icons">shopping_basket</span>
<span i18n>({{basketCount()}})</span>
</a>
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':
+++ /dev/null
-<div class="row">
- <div class="col-lg-4">
- <h3 i18n>Basket View</h3>
- </div>
- <div class="col-lg-8">
- <div class="float-right">
- <eg-catalog-result-pagination></eg-catalog-result-pagination>
- </div>
- </div>
-</div>
-<div class="row"
- *ngFor="let summary of searchContext.result.records; let idx = index">
- <div class="col-lg-12">
- <ng-container *ngIf="summary">
- <eg-catalog-result-record [summary]="summary" [index]="idx">
- </eg-catalog-result-record>
- </ng-container>
- </div>
-</div>
-
+++ /dev/null
-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));
- }
-}
-
-
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: [
ResultPaginationComponent,
RecordPaginationComponent,
RecordActionsComponent,
- BasketActionsComponent,
- BasketComponent
+ BasketActionsComponent
],
imports: [
StaffCommonModule,
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: '',
path: 'search',
component: ResultsComponent
}, {
- path: 'basket',
- component: BasketComponent
- }, {
path: 'record/:id',
component: RecordComponent
}, {