LP1865898 Missing pieces mult-scan work flow improvements
authorBill Erickson <berickxx@gmail.com>
Wed, 23 Sep 2020 15:45:42 +0000 (11:45 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 8 Mar 2021 19:53:42 +0000 (14:53 -0500)
After an item is marked as missing pieces, select/focus the barcode
input so another item can easily be marked as missing pieces without
having to manually clear the form / reload the page.

Tweaks the "Cancel" button to use the text "Reset Form" once the current
item has been processed, since it can no longer be canceled, but the
form can be forceably cleared if desired.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Mike Risher <mrisher@catalyte.io>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/cat/item/missing-pieces.component.html
Open-ILS/src/eg2/src/app/staff/cat/item/missing-pieces.component.ts

index 2d09622..b19e0d7 100644 (file)
@@ -37,8 +37,9 @@
       <button class="btn btn-success" (click)="processItem()" i18n>
         Mark Item as Missing Pieces?
       </button>
-      <button class="btn btn-warning ml-2" (click)="reset()" i18n>
-        Cancel
+      <button class="btn btn-warning ml-2" (click)="reset()">
+        <ng-container *ngIf="!itemProcessed" i18n>Cancel</ng-container>
+        <ng-container *ngIf="itemProcessed" i18n>Reset Form</ng-container>
       </button>
     </div>
   </div>
index 638db28..01d0757 100644 (file)
@@ -1,4 +1,4 @@
-import {Component, Input, AfterViewInit, ViewChild, Renderer2} from '@angular/core';
+import {Component, Input, AfterViewInit, ViewChild} from '@angular/core';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
 import {IdlObject} from '@eg/core/idl.service';
 import {PcrudService} from '@eg/core/pcrud.service';
@@ -21,13 +21,13 @@ export class MarkItemMissingPiecesComponent implements AfterViewInit {
     circNotFound = false;
     processing = false;
     noSuchItem = false;
+    itemProcessed = false;
 
     @ViewChild('penaltyDialog', {static: false})
     penaltyDialog: PatronPenaltyDialogComponent;
 
     constructor(
         private route: ActivatedRoute,
-        private renderer: Renderer2,
         private net: NetService,
         private printer: PrintService,
         private pcrud: PcrudService,
@@ -40,7 +40,7 @@ export class MarkItemMissingPiecesComponent implements AfterViewInit {
 
     ngAfterViewInit() {
         if (this.itemId) { this.getItemById(); }
-        this.renderer.selectRootElement('#item-barcode-input').focus();
+        this.selectInput();
     }
 
     getItemByBarcode(): Promise<any> {
@@ -49,6 +49,11 @@ export class MarkItemMissingPiecesComponent implements AfterViewInit {
 
         if (!this.itemBarcode) { return Promise.resolve(); }
 
+        // Submitting a new barcode resets the form.
+        const bc = this.itemBarcode;
+        this.reset();
+        this.itemBarcode = bc;
+
         return this.holdings.getItemIdFromBarcode(this.itemBarcode)
         .then(id => {
             this.noSuchItem = (id === null);
@@ -58,8 +63,11 @@ export class MarkItemMissingPiecesComponent implements AfterViewInit {
     }
 
     selectInput() {
-        setTimeout(() =>
-            this.renderer.selectRootElement('#item-barcode-input').select());
+        setTimeout(() => {
+            const node: HTMLInputElement =
+                document.getElementById('item-barcode-input') as HTMLInputElement;
+            if (node) { node.select(); }
+        });
     }
 
     getItemById(): Promise<any> {
@@ -101,12 +109,15 @@ export class MarkItemMissingPiecesComponent implements AfterViewInit {
     reset() {
         this.item = null;
         this.itemId = null;
+        this.letter = null;
         this.itemBarcode = null;
         this.circNotFound = false;
+        this.itemProcessed = false;
     }
 
     processItem() {
         this.circNotFound = false;
+        this.itemProcessed = false;
 
         if (!this.item) { return; }
 
@@ -119,9 +130,11 @@ export class MarkItemMissingPiecesComponent implements AfterViewInit {
         ).subscribe(resp => {
             const evt = this.evt.parse(resp); // always returns event
             this.processing = false;
+            this.itemProcessed = true;
 
             if (evt.textcode === 'ACTION_CIRCULATION_NOT_FOUND') {
                 this.circNotFound = true;
+                this.selectInput();
                 return;
             }
 
@@ -142,7 +155,12 @@ export class MarkItemMissingPiecesComponent implements AfterViewInit {
             if (payload.circ) {
                 this.penaltyDialog.patronId = payload.circ.usr();
                 this.penaltyDialog.open().subscribe(
-                    penId => console.debug('Applied penalty ', penId));
+                    penId => console.debug('Applied penalty ', penId),
+                    err => {},
+                    () => this.selectInput()
+                );
+            } else {
+                this.selectInput();
             }
         });
     }