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')
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?
41 console.debug('Performing basket action', this.basketAction);
43 switch (this.basketAction) {
45 // This does not propagate search params -- unclear if needed.
46 this.router.navigate(['/staff/catalog/search'],
47 {queryParams: {showBasket: true}});
51 this.basket.removeAllRecordIds();
55 this.basket.getRecordIds().then(ids => {
56 this.router.navigate(['/staff/catalog/hold/T'],
57 {queryParams: {target: ids}});
62 this.basket.getRecordIds().then(ids => {
65 'open-ils.search.biblio.record.print', ids
69 const html = at_event.template_output().data();
72 printContext: 'default'
80 this.basket.getRecordIds().then(ids => {
83 'open-ils.search.biblio.record.email',
84 this.auth.token(), ids
85 ).toPromise(); // fire-and-forget
91 ['/staff/cat/vandelay/export/basket'],
92 {queryParamsHandling: 'merge'}
97 this.basket.getRecordIds().then(ids => {
98 this.addToBucketDialog.bucketClass = 'biblio';
99 this.addToBucketDialog.itemIds = ids;
100 this.addToBucketDialog.open({size: 'lg'});
106 // Resetting basketAction inside its onchange handler
107 // prevents the new value from propagating to Angular
108 // Reset after the current thread.
109 setTimeout(() => this.basketAction = ''); // reset