-import { Component, Input, OnInit, AfterViewInit, QueryList, ViewChildren, ViewChild } from '@angular/core';
+import {Component, Input, OnInit, AfterViewInit, QueryList, ViewChildren, ViewChild} from '@angular/core';
import {Router, ActivatedRoute, ParamMap} from '@angular/router';
import {single} from 'rxjs/operators';
-import { NgbTimeStruct } from '@ng-bootstrap/ng-bootstrap';
-import { AuthService } from '@eg/core/auth.service';
+import {NgbTimeStruct} from '@ng-bootstrap/ng-bootstrap';
+import {AuthService} from '@eg/core/auth.service';
import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
import {DateSelectComponent} from '@eg/share/date-select/date-select.component';
import {DateRangeSelectComponent} from '@eg/share/daterange-select/daterange-select.component';
import {GridComponent} from '@eg/share/grid/grid.component';
import {GridDataSource, GridRowFlairEntry} from '@eg/share/grid/grid';
import {IdlObject} from '@eg/core/idl.service';
+import {NetService} from '@eg/core/net.service';
import {PcrudService} from '@eg/core/pcrud.service';
import {ServerStoreService} from '@eg/core/server-store.service';
import {ToastService} from '@eg/share/toast/toast.service';
constructor(
private auth: AuthService,
private format: FormatService,
+ private net: NetService,
private pcrud: PcrudService,
private route: ActivatedRoute,
private router: Router,
this.resourceId = res.id();
this.fetchData('resource', this.resourceId);
}, (err) => {
- this.resourceId = -1;
- this.toast.danger('No resource found with this barcode');
+ this.pcrud.search('acp',
+ {'barcode' : this.resourceBarcode}, {'limit': 1})
+ .pipe(single())
+ .subscribe((item) => {
+ this.net.request( 'open-ils.booking',
+ 'open-ils.booking.resources.create_from_copies',
+ this.auth.token(), [item.id()])
+ .subscribe((response) => {
+ this.toast.info('Made this barcode bookable');
+ this.resourceId = response['id'];
+ }, (error) => {
+ this.toast.danger('Cannot make this barcode bookable');
+ })
+ }, (acperror) => {
+ this.toast.danger('No resource found with this barcode');
+ this.resourceId = -1;
+ });
});
}
});