1 import {Component, OnInit, ViewChild} from '@angular/core';
2 import {BasketService} from '@eg/share/catalog/basket.service';
3 import {Router} from '@angular/router';
4 import {NetService} from '@eg/core/net.service';
5 import {AuthService} from '@eg/core/auth.service';
6 import {PrintService} from '@eg/share/print/print.service';
7 import {BucketDialogComponent
8 } from '@eg/staff/share/buckets/bucket-dialog.component';
11 selector: 'eg-catalog-basket-actions',
12 templateUrl: 'basket-actions.component.html'
14 export class BasketActionsComponent implements OnInit {
18 @ViewChild('addBasketToBucketDialog', { static: true })
19 addToBucketDialog: BucketDialogComponent;
22 private router: Router,
23 private net: NetService,
24 private auth: AuthService,
25 private printer: PrintService,
26 private basket: BasketService
28 this.basketAction = '';
34 basketCount(): number {
35 return this.basket.recordCount();
38 // TODO: confirmation dialogs?
40 applyAction(action: string) {
41 this.basketAction = action;
42 console.debug('Performing basket action', this.basketAction);
44 switch (this.basketAction) {
46 // This does not propagate search params -- unclear if needed.
47 this.router.navigate(['/staff/catalog/search'],
48 {queryParams: {showBasket: true}});
52 this.basket.removeAllRecordIds();
56 this.basket.getRecordIds().then(ids => {
57 this.router.navigate(['/staff/catalog/hold/T'],
58 {queryParams: {target: ids}});
63 this.basket.getRecordIds().then(ids => {
66 'open-ils.search.biblio.record.print', ids
70 const html = at_event.template_output().data();
73 printContext: 'default'
81 this.basket.getRecordIds().then(ids => {
84 'open-ils.search.biblio.record.email',
85 this.auth.token(), ids
86 ).toPromise(); // fire-and-forget
92 ['/staff/cat/vandelay/export/basket'],
93 {queryParamsHandling: 'merge'}
98 this.basket.getRecordIds().then(ids => {
99 this.addToBucketDialog.bucketClass = 'biblio';
100 this.addToBucketDialog.itemIds = ids;
101 this.addToBucketDialog.open({size: 'lg'});
107 // Resetting basketAction inside its onchange handler
108 // prevents the new value from propagating to Angular
109 // Reset after the current thread.
110 setTimeout(() => this.basketAction = ''); // reset