From fad0e712ccba16dde72eb26352c3c6013a58057b Mon Sep 17 00:00:00 2001 From: Bill Erickson <berickxx@gmail.com> Date: Thu, 26 Dec 2019 10:28:59 -0500 Subject: [PATCH] LP1852782 Fast add item option Signed-off-by: Bill Erickson <berickxx@gmail.com> Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu> --- .../app/staff/share/holdings/holdings.service.ts | 8 +++++--- .../staff/share/marc-edit/editor.component.html | 18 ++++++++++++++++ .../app/staff/share/marc-edit/editor.component.ts | 24 +++++++++++++++++++++- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts index 3c703e6373..5c91a68474 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts @@ -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[] = []; diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html index f574604470..77d4f009f9 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html @@ -18,6 +18,24 @@ <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"> diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts index c03e0e76bb..7c0a224f45 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts @@ -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]); + } + } } -- 2.11.0