return this.setRecordIds(wantedIds); // OK if empty
}
+
+ removeAllRecordIds(): Promise<number[]> {
+ return this.setRecordIds([]);
+ }
}
--- /dev/null
+
+<div class="row">
+ <div class="col-lg-4 pr-1">
+ <div class="float-right">
+ <a routerLink="/staff/catalog/basket" class="label-with-material-icon">
+ <span class="material-icons">shopping_basket</span>
+ <span i18n>({{basketCount()}})</span>
+ </a>
+ </div>
+ </div>
+ <div class="col-lg-8 pl-1">
+ <select class="form-control"
+ [(ngModel)]="basketAction" (change)="applyAction()">
+ <option value='' [disabled]="true" i18n>Basket Actions...</option>
+ <option value="view" i18n>View Basket</option>
+ <option value="hold" [disabled]="true" i18n>Place Hold</option>
+ <option value="print" [disabled]="true" i18n>Print Title Details</option>
+ <option value="email" [disabled]="true" i18n>Email Title Details</option>
+ <option value="bucket" [disabled]="true" i18n>Add Basket to Bucket</option>
+ <option value="clear" [disabled]="true" i18n>Clear Bucket</option>
+ </select>
+ </div>
+</div>
--- /dev/null
+import {Component, OnInit} from '@angular/core';
+import {BasketService} from '@eg/share/catalog/basket.service';
+import {Subscription} from 'rxjs/Subscription';
+import {Router} from '@angular/router';
+
+@Component({
+ selector: 'eg-catalog-basket-actions',
+ templateUrl: 'basket-actions.component.html'
+})
+export class BasketActionsComponent implements OnInit {
+
+ basketAction: string;
+
+ constructor(
+ private router: Router,
+ private basket: BasketService
+ ) {
+ this.basketAction = '';
+ }
+
+ ngOnInit() {
+ }
+
+ basketCount(): number {
+ return this.basket.recordCount();
+ }
+
+ applyAction() {
+ console.debug('Performing basket action', this.basketAction);
+
+ switch(this.basketAction) {
+ case 'view':
+ this.router.navigate(['/staff/catalog/basket']);
+ break;
+
+ case 'clear':
+ this.basket.removeAllRecordIds();
+ break;
+ }
+
+ // Resetting basketAction inside its onchange handler
+ // prevents the new value from propagating to Angular
+ // Reset after the current thread.
+ setTimeout(() => this.basketAction = ''); // reset
+ }
+}
+
+
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';
@NgModule({
declarations: [
ResultFacetsComponent,
ResultPaginationComponent,
RecordPaginationComponent,
- RecordActionsComponent
+ RecordActionsComponent,
+ BasketActionsComponent
],
imports: [
StaffCommonModule,
<input type='checkbox' [(ngModel)]="allRecsSelected"
(change)="toggleAllRecsSelected()"/>
<span class="pl-1" i18n>Select {{searchContext.pager.rowNumber(0)}} -
- {{searchContext.pager.rowNumber(searchContext.pager.limit - 1)}}
+ {{searchContext.pager.rowNumber(searchContext.currentResultIds().length - 1)}}
</span>
</label>
</div>
searchSub: Subscription;
routeSub: Subscription;
+ basketSub: Subscription;
constructor(
private route: ActivatedRoute,
// After each completed search, update the record selector.
this.searchSub = this.cat.onSearchComplete.subscribe(
ctx => this.applyRecordSelection());
+
+ // Watch for basket changes applied by other components.
+ this.basketSub = this.basket.onChange.subscribe(
+ () => this.applyRecordSelection());
}
ngOnDestroy() {
this.routeSub.unsubscribe();
this.searchSub.unsubscribe();
+ this.basketSub.unsubscribe();
}
// Apply the select-all checkbox when all visible records
switch (pageCount) {
case 1:
return this.searchContext.result.records[0];
- case 2:
- return this.searchContext.result.records[0]
- && this.searchContext.result.records[1];
default:
return this.searchContext.result.records[0]
- && this.searchContext.result.records[1]
- && this.searchContext.result.records[2];
+ && this.searchContext.result.records[1];
}
}
</div>
</div>
<div class="col-lg-3">
- <!--
- <div *ngIf="searchIsActive()">
- <div class="progress">
- <div class="progress-bar progress-bar-striped active w-100"
- role="progressbar" aria-valuenow="100"
- aria-valuemin="0" aria-valuemax="100">
- <span class="sr-only" i18n>Searching..</span>
- </div>
- </div>
- </div>
- -->
+ <eg-catalog-basket-actions></eg-catalog-basket-actions>
</div>
</div>
<div class="row pt-2" *ngIf="showAdvanced()">