1 import {Component, Input, OnInit, ViewChild} from '@angular/core';
2 import {FormControl} from '@angular/forms';
3 import {takeLast} from 'rxjs/operators';
4 import {DialogComponent} from '@eg/share/dialog/dialog.component';
5 import {AuthService} from '@eg/core/auth.service';
6 import {NetService} from '@eg/core/net.service';
7 import {EventService} from '@eg/core/event.service';
8 import {ToastService} from '@eg/share/toast/toast.service';
9 import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
10 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
11 import {StringComponent} from '@eg/share/string/string.component';
14 selector: 'eg-add-to-carousel-dialog',
15 templateUrl: './add-to-carousel-dialog.component.html'
19 export class AddToCarouselDialogComponent extends DialogComponent implements OnInit {
21 // IDs of records to add to the carousel
22 @Input() recordIds: number[];
25 @ViewChild('successMsg', { static: true }) private successMsg: StringComponent;
26 @ViewChild('errorMsg', { static: true }) private errorMsg: StringComponent;
28 selectedCarousel = new FormControl('');
30 private carousels = [];
32 public addToCarousel: () => void;
33 private reset: () => void;
36 private modal: NgbModal,
37 private auth: AuthService,
38 private evt: EventService,
39 private net: NetService,
40 private toast: ToastService
46 this.onOpen$.subscribe(ok => {
50 'open-ils.actor.carousel.retrieve_manual_by_staff',
52 ).subscribe(carousels => this.carousels = carousels);
59 this.addToCarousel = () => {
62 'open-ils.actor.container.item.create.batch',
64 'biblio_record_entry',
65 this.selectedCarousel.value['id'],
70 const evt = this.evt.parse(result);
72 this.errorMsg.current().then(m => this.toast.danger(m));
74 this.successMsg.current().then(m => this.toast.success(m));
82 formatCarouselEntries(): ComboboxEntry[] {
83 return this.carousels.map(carousel => ({id: carousel['bucket'], label: carousel['name']}));