LP1852782 Fast add item option
authorBill Erickson <berickxx@gmail.com>
Thu, 26 Dec 2019 15:28:59 +0000 (10:28 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 21 Feb 2020 16:44:38 +0000 (11:44 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts
Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html
Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts

index 3c703e6..5c91a68 100644 (file)
@@ -8,8 +8,10 @@ import {AuthService} from '@eg/core/auth.service';
 import {EventService} from '@eg/core/event.service';
 
 interface NewCallNumData {
-    owner: number;
+    owner?: number;
     label?: string;
+    fast_add?: boolean;
+    barcode?: string;
 }
 
 @Injectable()
@@ -25,8 +27,8 @@ export class HoldingsService {
     // Open the holdings editor UI in a new browser window/tab.
     spawnAddHoldingsUi(
         recordId: number,               // Bib record ID
-        addToCallNums?: number[],           // Add copies to / modify existing CNs
-        callNumData?: NewCallNumData[],   // Creating new call numbers
+        addToCallNums?: number[],       // Add copies to / modify existing CNs
+        callNumData?: NewCallNumData[], // Creating new call numbers
         hideCopies?: boolean) {         // Hide the copy edit pane
 
         const raw: any[] = [];
index f574604..77d4f00 100644 (file)
 <eg-string #failMsg i18n-text text="Record failed to update"></eg-string>
 
 <div class="row d-flex p-2 m-2">
+
+  <div class="form-check">
+    <input class="form-check-input" type="checkbox"
+      [(ngModel)]="showFastAdd" id="fast-add-item"/>
+    <label class="form-check-label" for="fast-add-item">
+      Add Item
+    </label>
+  </div>
+
+  <ng-container *ngIf="showFastAdd">
+    <div class="form-inline">
+      <input type="text" class="form-control ml-2" 
+        [(ngModel)]="fastItemLabel" placeholder="Call Number" i18n-placeholder/>
+      <input type="text" class="form-control ml-2" 
+        [(ngModel)]="fastItemBarcode" placeholder="Barcode" i18n-placeholder/>
+    </div>
+  </ng-container>
+
   <div class="flex-1"></div>
 
   <h3 class="mr-2">
index c03e0e7..7c0a224 100644 (file)
@@ -14,6 +14,7 @@ import {ComboboxEntry, ComboboxComponent
 import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
 import {MarcEditContext} from './editor-context';
 import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
+import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
 
 interface MarcSavedEvent {
     marcXml: string;
@@ -82,6 +83,10 @@ export class MarcEditorComponent implements OnInit {
     @ViewChild('successMsg', {static: false}) successMsg: StringComponent;
     @ViewChild('failMsg', {static: false}) failMsg: StringComponent;
 
+    fastItemLabel: string;
+    fastItemBarcode: string;
+    showFastAdd: boolean;
+
     constructor(
         private evt: EventService,
         private idl: IdlService,
@@ -90,6 +95,7 @@ export class MarcEditorComponent implements OnInit {
         private org: OrgService,
         private pcrud: PcrudService,
         private toast: ToastService,
+        private holdings: HoldingsService,
         private store: ServerStoreService
     ) {
         this.sources = [];
@@ -184,13 +190,14 @@ export class MarcEditorComponent implements OnInit {
         // NOTE we do not reinitialize our record with the MARC returned
         // from the server after a create/update, which means our record
         // may be out of sync, e.g. missing 901* values.  It's the
-        // callers onsibility to tear us down and rebuild us.
+        // callers responsibility to tear us down and rebuild us.
         return promise.then(marcXml => {
             if (!marcXml) { return null; }
             this.successMsg.current().then(msg => this.toast.success(msg));
             emission.marcXml = marcXml;
             emission.recordId = this.recordId;
             this.recordSaved.emit(emission);
+            this.fastAdd();
             return marcXml;
         });
     }
@@ -305,5 +312,20 @@ export class MarcEditorComponent implements OnInit {
             });
         });
     }
+
+    // Spawns the copy editor with the requested barcode and
+    // call number label.  Called after our record is saved.
+    fastAdd() {
+        if (this.showFastAdd && this.fastItemLabel && this.fastItemBarcode) {
+
+            const fastItem = {
+                label: this.fastItemLabel,
+                barcode: this.fastItemBarcode,
+                fast_add: true
+            };
+
+            this.holdings.spawnAddHoldingsUi(this.recordId, null, [fastItem]);
+        }
+    }
 }