</eg-patron-search-dialog>
<div class="row">
- <div class="col-lg-4">
+ <div class="col-lg-1">
+ <button class="btn btn-info label-with-material-icon"
+ (click)="goBack()" [disabled]="hasNoHistory()">
+ <span class="material-icons">keyboard_backspace</span>
+ <span i18n>Return</span>
+ </button>
+ </div>
+ <div class="col-lg-5">
<ng-container *ngIf="badBarcode">
<div class="alert alert-danger" i18n>
Barcode '{{badBarcode}}' not found.
</h3>
</ng-container>
</div>
- <div class="col-lg-2 text-right">
+ <div class="col-lg-2">
<button class="btn btn-outline-dark btn-sm" (click)="searchPatrons()">
<span class="material-icons mat-icon-in-button align-middle"
i18n-title title="Search for Patron">search</span>
this.staffCat.clearHoldPatron();
}
- this.resetForm();
- this.userBarcode = newBc; // clobbered in reset
-
this.currentUserBarcode = this.userBarcode;
this.getUser();
}
getUser(id?: number) {
+
+ this.resetForm(true);
+
const flesh = {flesh: 1, flesh_fields: {au: ['settings']}};
const promise = id ? this.patron.getById(id, flesh) :
});
}
- resetForm() {
+ resetForm(keepBarcode?: boolean) {
this.user = null;
- this.userBarcode = null;
this.notifyEmail = true;
this.notifyPhone = true;
this.phoneValue = '';
this.pickupLib = this.requestor.ws_ou();
this.placeHoldsClicked = false;
+ // Avoid clearing the barcode in cases where the form is
+ // reset as the result of a barcode change.
+ if (!keepBarcode) { this.userBarcode = null; }
+
this.holdContexts = this.holdTargets.map(target => {
const ctx = new HoldContext(target);
return ctx;
ctx.holdMeta.part = null;
}
}
+
+ hasNoHistory(): boolean {
+ return history.length === 0;
+ }
+
+ goBack() {
+ history.back();
+ }
}
advanced: 'term'
};
+// Automatically collapse the search form on these pages
+const COLLAPSE_ON_PAGES = [
+ new RegExp(/catalog\/record\//),
+ new RegExp(/catalog\/hold\//)
+];
+
@Component({
selector: 'eg-catalog-search-form',
styleUrls: ['search-form.component.css'],
this.router.events.subscribe(routeEvent => {
if (routeEvent instanceof NavigationEnd) {
- if (routeEvent.url.match(/catalog\/record/)) {
- this.showThyself = false;
- } else {
- this.showThyself = true;
- }
+ this.showThyself = true;
+ COLLAPSE_ON_PAGES.forEach(pageRegex => {
+ if (routeEvent.url.match(pageRegex)) {
+ this.showThyself = false;
+ }
+ });
}
});
}