<input type="text" class="form-control" id="barcode-input"
[placeholder]="checkoutNoncat ? '' : 'Barcode...'" i18n-placeholder
[(ngModel)]="checkoutBarcode" [disabled]="checkoutNoncat != null"
- i18n-aria-label aria-label="Barcode Input" (keyup.enter)="checkout()" />
+ i18n-aria-label aria-label="Barcode Input" (keydown.enter)="checkout()" />
<div class="input-group-append">
- <button class="btn btn-outline-dark" (keyup.enter)="checkout()"
+ <button class="btn btn-outline-dark" (keydown.enter)="checkout()"
(click)="checkout()" i18n>Submit</button>
</div>
</div>
} else if (this.checkoutBarcode) {
- if (this.copiesInFlight[this.checkoutBarcode]) {
- console.log('Item ' +
- this.checkoutBarcode + ' is already mid-checkout');
- return Promise.resolve(null);
- }
-
- this.copiesInFlight[this.checkoutBarcode] = true;
-
params.copy_barcode = this.checkoutBarcode;
if (this.dueDateOptions > 0) { params.due_date = this.dueDate; }
return Promise.resolve(params);
return Promise.resolve(null);
}
- checkout() {
- this.collectParams()
+ checkout(params?: CheckoutParams, override?: boolean): Promise<CheckoutResult> {
- .then((params: CheckoutParams) => {
+ const barcode = params.copy_barcode || '';
+
+ if (barcode) {
+
+ if (this.copiesInFlight[barcode]) {
+ console.debug('Item ' + barcode + ' is already mid-checkout');
+ return Promise.resolve(null);
+ }
+
+ this.copiesInFlight[barcode] = true;
+ }
+
+ const promise = params ? Promise.resolve(params) : this.collectParams();
+
+ promise.then((params: CheckoutParams) => {
if (params) {
return this.circ.checkout(params);
}
.then((result: CheckoutResult) => {
if (result) {
- if (result.params.copy_barcode) {
- delete this.copiesInFlight[result.params.copy_barcode];
- }
this.dispatchResult(result);
+ return result;
}
- });
+ })
+
+ .finally(() => delete this.copiesInFlight[barcode]);
}
dispatchResult(result: CheckoutResult) {
}
handlePrecat(result: CheckoutResult) {
- this.precatDialog.open({size: 'lg'}).subscribe(values => {
- console.log('precat values', values);
+ this.precatDialog.open().subscribe(values => {
+ if (values && values.dummy_title) {
+ const params = result.params;
+ params.precat = true;
+ Object.keys(values).forEach(key => params[key] = values[key]);
+ this.checkout(params);
+ }
})
}
}
</button>
</div>
<div class="modal-body">
+
<div class="row">
+ <div class="col-lg-4" i18n>Title</div>
+ <div class="col-lg-8">
+ <input class="form-control" [(ngModel)]="values.dummy_title"
+ id='precat-title-input' i18n-placeholder placeholder="Title..."/>
+ </div>
+ </div>
+
+ <div class="row mt-2">
+ <div class="col-lg-4" i18n>Author</div>
+ <div class="col-lg-8">
+ <input class="form-control" [(ngModel)]="values.dummy_author"
+ i18n-placeholder placeholder="Author..."/>
+ </div>
+ </div>
+
+ <div class="row mt-2">
+ <div class="col-lg-4" i18n>ISBN</div>
+ <div class="col-lg-8">
+ <input class="form-control" [(ngModel)]="values.dummy_isbn"
+ i18n-placeholder placeholder="ISBN..."/>
+ </div>
+ </div>
+
+ <div class="row mt-2">
<div class="col-lg-4" i18n>Circulation Modifier</div>
<div class="col-lg-8">
- <eg-combobox idlClass="ccm" [(ngModel)]="circModifier"></eg-combobox>
+ <eg-combobox idlClass="ccm"
+ i18n-placeholder placeholder="Circulation Modifier..."
+ (onChange)="values.circ_modifier = $event ? $event.id : null">
+ </eg-combobox>
</div>
</div>
</div>
<div class="modal-footer">
- <!-- has perm -->
+ <button type="button" class="btn btn-success" (click)="close(values)"
+ [disabled]="!hasPerm || !values.dummy_title" i18n>Submit</button>
+ <button type="button" class="btn btn-warning" (click)="close()" i18n>Cancel</button>
</div>
</ng-template>
circModifier: ComboboxEntry;
hasPerm = false;
+ values = {
+ dummy_title: null,
+ dummy_author: null,
+ dummy_isbn: null,
+ circ_modifier: null
+ };
+
constructor(
private perm: PermService,
private modal: NgbModal) {
}
ngOnInit() {
- this.perm.hasWorkPermHere('CREATE_PRECAT')
- .then(perms => this.hasPerm = perms['CREATE_PRECAT']);
+ this.onOpen$.subscribe(_ => {
+ this.perm.hasWorkPermHere('CREATE_PRECAT')
+ .then(perms => this.hasPerm = perms['CREATE_PRECAT']);
+
+ const node = document.getElementById('precat-title-input');
+ if (node) { node.focus(); }
+ });
}
}
// API parameter options
export interface CheckoutParams {
- due_date?: string;
patron_id: number;
+ due_date?: string;
copy_id?: number;
copy_barcode?: string;
noncat?: boolean;
noncat_type?: number;
noncat_count?: number;
noop?: boolean;
+ precat?: boolean;
+ dummy_title?: string;
+ dummy_author?: string;
+ dummy_isbn?: string;
+ circ_modifier?: string;
}
export interface CheckoutResult {