this.translator.fieldName = field;
this.translator.idlObject = this.record;
- // TODO: will need to change once LP1823041 is merged
- this.translator.open().then(
+ this.translator.open().subscribe(
newValue => {
if (newValue) {
this.record[field](newValue);
}
- },
- () => {} // avoid console error
+ }
);
}
}
this.editDialog.mode = 'update';
this.editDialog.setRecord(this.selected.callerData.aout);
- this.editDialog.open().then(
+ this.editDialog.open().subscribe(
success => {
this.postUpdate(this.editString);
this.loadAoutTree(); // since the tree is never going to
}
remove() {
- this.delConfirm.open().then(
+ this.delConfirm.open().subscribe(
ok => {
this.pcrud.remove(this.selected.callerData.aout)
.subscribe(
this.postUpdate(this.editString);
}
);
- },
- notConfirmed => {}
+ }
);
}
this.editDialog.setRecord(newType);
this.editDialog.mode = 'create';
- this.editDialog.open().then(
+ this.editDialog.open().subscribe(
result => { // aout object
// Add our new node to the tree
this.basket.getRecordIds().then(ids => {
this.addToBucketDialog.bucketClass = 'biblio';
this.addToBucketDialog.itemIds = ids;
- this.addToBucketDialog.open({size: 'lg'}).then(
- ok => {},
- dismissed => {}
- );
+ this.addToBucketDialog.open({size: 'lg'});
});
break;
}
openConjoinedDialog() {
- this.conjoinedDialog.open({size: 'sm'}).then(
+ this.conjoinedDialog.open({size: 'sm'}).subscribe(
modified => {
if (modified) {
this.grid.reload();
}
- },
- notOk => {}
+ }
);
}
}
}
this.markDamagedDialog.copyId = ids.pop();
- return this.markDamagedDialog.open({size: 'lg'}).then(
+ return this.markDamagedDialog.open({size: 'lg'}).subscribe(
ok => {
if (ok) { rowsModified = true; }
return markNext(ids);
const copyIds = this.selectedCopyIds(rows, 4 /* ignore missing */);
if (copyIds.length > 0) {
this.markMissingDialog.copyIds = copyIds;
- this.markMissingDialog.open({}).then(
+ this.markMissingDialog.open({}).subscribe(
rowsModified => {
if (rowsModified) {
this.refreshHoldings = true;
this.copyAlertsDialog.copyIds = copyIds;
this.copyAlertsDialog.mode = mode;
- this.copyAlertsDialog.open({size: 'lg'}).then(
+ this.copyAlertsDialog.open({size: 'lg'}).subscribe(
modified => {
if (modified) {
this.hardRefresh();
}
- },
- dismissed => {}
+ }
);
}
const ids = this.selectedCopyIds(rows);
if (ids.length === 0) { return; }
this.replaceBarcode.copyIds = ids;
- this.replaceBarcode.open({}).then(
+ this.replaceBarcode.open({}).subscribe(
modified => {
if (modified) {
this.hardRefresh();
}
- },
- dismissed => {}
+ }
);
}
// "both" mode.
this.deleteVolcopy.forceDeleteCopies = mode === 'both';
this.deleteVolcopy.volumes = Object.values(volHash);
- this.deleteVolcopy.open({size: 'sm'}).then(
+ this.deleteVolcopy.open({size: 'sm'}).subscribe(
modified => {
if (modified) {
this.hardRefresh();
}
- },
- dismissed => {}
+ }
);
}
if (copyIds.length > 0) {
this.bucketDialog.bucketClass = 'copy';
this.bucketDialog.itemIds = copyIds;
- this.bucketDialog.open({size: 'lg'}).then(
- // No need to reload the grid after adding items to buckets.
- ok => {},
- dismissed => {}
- );
+ this.bucketDialog.open({size: 'lg'});
}
}
const copyIds = this.selectedCopyIds(rows);
if (copyIds.length > 0) {
this.conjoinedDialog.copyIds = copyIds;
- this.conjoinedDialog.open({size: 'sm'}).then(
- ok => {}, // No grid reload required
- dismissed => {}
- );
+ this.conjoinedDialog.open({size: 'sm'});
}
}
const copyIds = this.selectedCopyIds(rows);
if (copyIds.length > 0) {
this.makeBookableDialog.copyIds = copyIds;
- this.makeBookableDialog.open({}).then(
- modified => {}, // No refresh needed
- dismissed => {}
- );
+ this.makeBookableDialog.open({});
}
}
}
// create action does not try to modify an existing record.
this.editDialog.recId = null;
this.editDialog.record = null;
- this.editDialog.open({size: this.dialogSize}).then(
+ this.editDialog.open({size: this.dialogSize}).subscribe(
ok => {
this.createString.current()
.then(str => this.toast.success(str));
import {Component, OnInit, Input, ViewChild} from '@angular/core';
+import {Observable, throwError} from 'rxjs';
import {NetService} from '@eg/core/net.service';
import {IdlService, IdlObject} from '@eg/core/idl.service';
import {EventService} from '@eg/core/event.service';
* Dialog promise resolves with true/false indicating whether
* the mark-damanged action occured or was dismissed.
*/
- async open(args: NgbModalOptions): Promise<boolean> {
+ open(args: NgbModalOptions): Observable<boolean> {
this.copy = null;
this.copies = [];
this.newAlert = this.idl.create('aca');
this.newAlert.create_staff(this.auth.user().id());
if (this.copyIds.length === 0) {
- return Promise.reject('copy ID required');
+ return throwError('copy ID required');
}
// In manage mode, we can only manage a single copy.
}
}
- await this.getAlertTypes();
- await this.getCopies();
- if (this.mode === 'manage') {
- await this.getCopyAlerts();
- }
- return super.open(args);
+ this.getAlertTypes()
+ .then(() => this.getCopies())
+ .then(() => {
+ if (this.mode === 'manage') {
+ this.getCopyAlerts()
+ .then(() => super.open(args) );
+ }
+ return super.open(args);
+ });
}
- async getAlertTypes(): Promise<any> {
+ getAlertTypes(): Promise<any> {
if (this.alertTypes) {
return Promise.resolve();
}
});
}
- async getCopies(): Promise<any> {
+ getCopies(): Promise<any> {
return this.pcrud.search('acp', {id: this.copyIds}, {}, {atomic: true})
.toPromise().then(copies => {
this.copies = copies;
// Copy alerts for the selected copies which have not been
// acknowledged by staff and are within org unit range of
// the alert type.
- async getCopyAlerts(): Promise<any> {
+ getCopyAlerts(): Promise<any> {
const copyIds = this.copies.map(c => c.id());
const typeIds = this.alertTypes.map(a => a.id);
import {Component, OnInit, Input, ViewChild, Renderer2} from '@angular/core';
+import {Observable, throwError} from 'rxjs';
import {IdlObject} from '@eg/core/idl.service';
import {NetService} from '@eg/core/net.service';
import {EventService} from '@eg/core/event.service';
ngOnInit() {}
- async open(args: NgbModalOptions): Promise<boolean> {
+ open(args: NgbModalOptions): Observable<boolean> {
this.numVols = 0;
this.numCopies = 0;
this.numSucceeded = 0;
if (this.numVols === 0 && this.numCopies === 0) {
console.debug('Volcopy delete called with no usable data');
- return Promise.resolve(false);
+ return throwError(false);
}
return super.open(args);
import {Component, OnInit, Input, ViewChild} from '@angular/core';
+import {Observable, throwError} from 'rxjs';
import {NetService} from '@eg/core/net.service';
import {IdlObject} from '@eg/core/idl.service';
import {EventService} from '@eg/core/event.service';
* Dialog promise resolves with true/false indicating whether
* the mark-damanged action occured or was dismissed.
*/
- async open(args: NgbModalOptions): Promise<boolean> {
+ open(args: NgbModalOptions): Observable<boolean> {
this.reset();
if (!this.copyId) {
- return Promise.reject('copy ID required');
+ return throwError('copy ID required');
}
- await this.getBillingTypes();
- await this.getData();
- return super.open(args);
+ this.getBillingTypes()
+ .then(() => { this.getData(); })
+ .then(() => super.open(args));
}
// Fetch-cache billing types
- async getBillingTypes(): Promise<any> {
+ getBillingTypes(): Promise<any> {
if (this.billingTypes.length > 1) {
return Promise.resolve();
}
});
}
- async getData(): Promise<any> {
+ getData(): Promise<any> {
return this.pcrud.retrieve('acp', this.copyId,
{flesh: 1, flesh_fields: {acp: ['call_number']}}).toPromise()
.then(copy => {
import {Component, OnInit, Input, ViewChild, Renderer2} from '@angular/core';
+import {Observable, throwError} from 'rxjs';
+import {flatMap, map, tap} from 'rxjs/operators';
import {IdlObject} from '@eg/core/idl.service';
import {NetService} from '@eg/core/net.service';
import {EventService} from '@eg/core/event.service';
ngOnInit() {}
- async open(args: NgbModalOptions): Promise<boolean> {
+ open(args: NgbModalOptions): Observable<boolean> {
this.ids = [].concat(this.copyIds);
this.numSucceeded = 0;
this.numFailed = 0;
- await this.getNextCopy();
- setTimeout(() =>
- // Give the dialog a chance to render
- this.renderer.selectRootElement('#new-barcode-input').focus()
- );
- return super.open(args);
+ return this.getNextCopy()
+ .pipe(flatMap(() => {
+ return super.open(args)
+ .pipe(tap(() => {this.renderer.selectRootElement('#new-barcode-input').focus(); }));
+ }));
}
- async getNextCopy(): Promise<any> {
+ getNextCopy(): Observable<any> {
if (this.ids.length === 0) {
this.close(this.numSucceeded > 0);
- return Promise.resolve();
+ return throwError(false);
}
this.newBarcode = '';
const id = this.ids.pop();
return this.pcrud.retrieve('acp', id)
- .toPromise().then(c => this.copy = c);
+ .pipe(map(c => this.copy = c));
}
async replaceOneBarcode(): Promise<any> {
import {Component, OnInit, Input, ViewChild} from '@angular/core';
+import {Observable} from 'rxjs';
import {NetService} from '@eg/core/net.service';
import {EventService} from '@eg/core/event.service';
import {ToastService} from '@eg/share/toast/toast.service';
// them to load regardless of whether the dialog is ever used.
}
- open(args: NgbModalOptions): Promise<boolean> {
+ open(args: NgbModalOptions): Observable<boolean> {
if (this.cancelReasons.length === 0) {
this.pcrud.retrieveAll('ahrcc', {}, {atomic: true}).toPromise()
const holdIds = rows.map(r => r.id).filter(id => Boolean(id));
if (holdIds.length > 0) {
this.manageDialog.holdIds = holdIds;
- this.manageDialog.open({size: 'lg'}).then(
+ this.manageDialog.open({size: 'lg'}).subscribe(
rowsModified => {
if (rowsModified) {
this.holdsGrid.reload();
}
- },
- dismissed => {}
+ }
);
}
}
const holdIds = rows.map(r => r.id).filter(id => Boolean(id));
if (holdIds.length > 0) {
this.transferDialog.holdIds = holdIds;
- this.transferDialog.open({}).then(
+ this.transferDialog.open({}).subscribe(
rowsModified => {
if (rowsModified) {
this.holdsGrid.reload();
}
- },
- dismissed => {}
+ }
);
}
}
}
this.markDamagedDialog.copyId = ids.pop();
- return this.markDamagedDialog.open({size: 'lg'}).then(
+ return this.markDamagedDialog.open({size: 'lg'}).subscribe(
ok => {
if (ok) { rowsModified = true; }
return markNext(ids);
const copyIds = rows.map(r => r.cp_id).filter(id => Boolean(id));
if (copyIds.length > 0) {
this.markMissingDialog.copyIds = copyIds;
- this.markMissingDialog.open({}).then(
+ this.markMissingDialog.open({}).subscribe(
rowsModified => {
if (rowsModified) {
this.holdsGrid.reload();
}
- },
- dismissed => {} // avoid console errors
+ }
);
}
}
const holdIds = rows.map(r => r.id).filter(id => Boolean(id));
if (holdIds.length > 0) {
this.retargetDialog.holdIds = holdIds;
- this.retargetDialog.open({}).then(
+ this.retargetDialog.open({}).subscribe(
rowsModified => {
if (rowsModified) {
this.holdsGrid.reload();
}
- },
- dismissed => {}
+ }
);
}
}
const holdIds = rows.map(r => r.id).filter(id => Boolean(id));
if (holdIds.length > 0) {
this.cancelDialog.holdIds = holdIds;
- this.cancelDialog.open({}).then(
+ this.cancelDialog.open({}).subscribe(
rowsModified => {
if (rowsModified) {
this.holdsGrid.reload();
}
- },
- dismissed => {}
+ }
);
}
}
import {Component, OnInit, Input} from '@angular/core';
+import {Observable} from 'rxjs';
import {DialogComponent} from '@eg/share/dialog/dialog.component';
import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
super(modal); // required for subclassing
}
- open(args: NgbModalOptions): Promise<boolean> {
+ open(args: NgbModalOptions): Observable<boolean> {
return super.open(args);
}
import {Component, OnInit, Input, ViewChild} from '@angular/core';
+import {Observable} from 'rxjs';
import {NetService} from '@eg/core/net.service';
import {EventService} from '@eg/core/event.service';
import {ToastService} from '@eg/share/toast/toast.service';
ngOnInit() {}
- open(args: NgbModalOptions): Promise<boolean> {
+ open(args: NgbModalOptions): Observable<boolean> {
this.holdIds = [].concat(this.holdIds); // array-ify ints
return super.open(args);
}
import {Component, OnInit, Input, ViewChild} from '@angular/core';
+import {Observable, throwError} from 'rxjs';
import {NetService} from '@eg/core/net.service';
import {StoreService} from '@eg/core/store.service';
import {EventService} from '@eg/core/event.service';
ngOnInit() {}
- async open(args: NgbModalOptions): Promise<boolean> {
+ open(args: NgbModalOptions): Observable<boolean> {
this.holdIds = [].concat(this.holdIds); // array-ify ints
this.transferTarget =
this.store.getLocalItem('eg.circ.hold.title_transfer_target');
if (!this.transferTarget) {
- this.toast.warning(await this.targetNeeded.current());
- return Promise.reject('Transfer Target Required');
+ this.targetNeeded.current()
+ .then((msg) => this.toast.warning(msg))
+ .then(() => throwError('Transfer Target Required'));
}
return super.open(args);