LP1889128 Holds reset repairs and making space user/berick/lp1887429-lp1889128-hold-prefs-and-multi
authorBill Erickson <berickxx@gmail.com>
Wed, 23 Sep 2020 19:20:42 +0000 (15:20 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 23 Sep 2020 19:20:44 +0000 (15:20 -0400)
Collapse the Search Form on the holds page so the holds form and data
have more vertical room on the page.  Additionally, to help alleviate
any confusion that may be caused by the collapsed search form (and
because it has come up in other conversations), add a 'Return' button to
the holds page so users have an obvious way back to the previous catalog
page.

Fixes an issue where setting the hold recipient from a patron to the
staff account failed to properly clear the holds form, leaving (e.g.)
the wrong pickup lib in the selector.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts

index e720c2f..566bbeb 100644 (file)
@@ -3,7 +3,14 @@
 </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.
@@ -17,7 +24,7 @@
       </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>
index ab7696f..a76cdb7 100644 (file)
@@ -307,14 +307,14 @@ export class HoldComponent implements OnInit {
             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) :
@@ -336,15 +336,18 @@ export class HoldComponent implements OnInit {
         });
     }
 
-    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;
@@ -517,6 +520,14 @@ export class HoldComponent implements OnInit {
             }
         );
     }
+
+    hasNoHistory(): boolean {
+        return history.length === 0;
+    }
+
+    goBack() {
+        history.back();
+    }
 }
 
 
index 9dcca68..4e37e5a 100644 (file)
@@ -15,6 +15,12 @@ const LEGACY_TAB_NAME_MAP = {
     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'],
@@ -54,11 +60,12 @@ export class SearchFormComponent implements OnInit, AfterViewInit {
 
         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;
+                    }
+                });
             }
         });
     }