From: Bill Erickson Date: Fri, 22 Mar 2019 16:44:20 +0000 (-0700) Subject: lpxxx Angular holdings maintenance wip X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c5b7ee978bdbdce51d5f99ad6daea1c6f62c1769;p=working%2FEvergreen.git lpxxx Angular holdings maintenance wip Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html index b7cfc57c92..4b46e62120 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html @@ -47,6 +47,7 @@ +
@@ -101,11 +102,31 @@ + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts index 707944d1d8..3e69e90b96 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts @@ -9,7 +9,8 @@ import {PcrudService} from '@eg/core/pcrud.service'; import {AuthService} from '@eg/core/auth.service'; import {GridDataSource} from '@eg/share/grid/grid'; import {GridComponent} from '@eg/share/grid/grid.component'; -import {GridToolbarCheckboxComponent} from '@eg/share/grid/grid-toolbar-checkbox.component'; +import {GridToolbarCheckboxComponent + } from '@eg/share/grid/grid-toolbar-checkbox.component'; import {StoreService} from '@eg/core/store.service'; import {ServerStoreService} from '@eg/core/server-store.service'; import {MarkDamagedDialogComponent @@ -18,8 +19,10 @@ import {MarkMissingDialogComponent } from '@eg/staff/share/holdings/mark-missing-dialog.component'; import {AnonCacheService} from '@eg/share/util/anon-cache.service'; import {HoldingsService} from '@eg/staff/share/holdings/holdings.service'; -import {CopyAlertsDialogComponent} from '@eg/staff/share/holdings/copy-alerts-dialog.component'; - +import {CopyAlertsDialogComponent + } from '@eg/staff/share/holdings/copy-alerts-dialog.component'; +import {ReplaceBarcodeDialogComponent + } from '@eg/staff/share/holdings/replace-barcode-dialog.component'; // The holdings grid models a single HoldingsTree, composed of HoldingsTreeNodes // flattened on-demand into a list of HoldingEntry objects. @@ -85,6 +88,8 @@ export class HoldingsMaintenanceComponent implements OnInit { private markMissingDialog: MarkMissingDialogComponent; @ViewChild('copyAlertsDialog') private copyAlertsDialog: CopyAlertsDialogComponent; + @ViewChild('replaceBarcode') + private replaceBarcode: ReplaceBarcodeDialogComponent; holdingsTree: HoldingsTree; @@ -747,4 +752,17 @@ export class HoldingsMaintenanceComponent implements OnInit { ) } + openReplaceBarcodeDialog(rows: HoldingsEntry[]) { + const ids = this.selectedCopyIds(rows); + if (ids.length === 0) { return; } + this.replaceBarcode.copyIds = ids; + this.replaceBarcode.open({}).then( + modified => { + if (modified) { + this.hardRefresh(); + } + }, + dismissed => {} + ); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.module.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.module.ts index e5789f67c6..c931a2fc27 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.module.ts @@ -4,12 +4,14 @@ import {HoldingsService} from './holdings.service'; import {MarkDamagedDialogComponent} from './mark-damaged-dialog.component'; import {MarkMissingDialogComponent} from './mark-missing-dialog.component'; import {CopyAlertsDialogComponent} from './copy-alerts-dialog.component'; +import {ReplaceBarcodeDialogComponent} from './replace-barcode-dialog.component'; @NgModule({ declarations: [ MarkDamagedDialogComponent, MarkMissingDialogComponent, - CopyAlertsDialogComponent + CopyAlertsDialogComponent, + ReplaceBarcodeDialogComponent ], imports: [ StaffCommonModule @@ -17,7 +19,8 @@ import {CopyAlertsDialogComponent} from './copy-alerts-dialog.component'; exports: [ MarkDamagedDialogComponent, MarkMissingDialogComponent, - CopyAlertsDialogComponent + CopyAlertsDialogComponent, + ReplaceBarcodeDialogComponent ], providers: [ HoldingsService 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 964ccf14ad..87b0ff1a9a 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 @@ -25,7 +25,7 @@ export class HoldingsService { // Open the holdings editor UI in a new browser window/tab. spawnAddHoldingsUi( recordId: number, // Bib record ID - addToVols?: number[], // Add copies to existing volumes + addToVols?: number[], // Add copies to / modify existing vols volumeData?: NewVolumeData[], // Creating new volumes hideCopies?: boolean) { // Hide the copy edit pane diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/replace-barcode-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/holdings/replace-barcode-dialog.component.html new file mode 100644 index 0000000000..437965c6de --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/replace-barcode-dialog.component.html @@ -0,0 +1,44 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/replace-barcode-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/replace-barcode-dialog.component.ts new file mode 100644 index 0000000000..552922e9a0 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/replace-barcode-dialog.component.ts @@ -0,0 +1,111 @@ +import {Component, OnInit, Input, ViewChild, Renderer2} from '@angular/core'; +import {IdlObject} from '@eg/core/idl.service'; +import {NetService} from '@eg/core/net.service'; +import {EventService} from '@eg/core/event.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {ToastService} from '@eg/share/toast/toast.service'; +import {AuthService} from '@eg/core/auth.service'; +import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {StringComponent} from '@eg/share/string/string.component'; + + +/** + * Dialog for marking items missing. + */ + +@Component({ + selector: 'eg-replace-barcode-dialog', + templateUrl: 'replace-barcode-dialog.component.html' +}) + +export class ReplaceBarcodeDialogComponent + extends DialogComponent implements OnInit { + + @Input() copyIds: number[]; + ids: number[]; // copy of list so we can pop() + + copy: IdlObject; + newBarcode: string; + barcodeExists: boolean; + + numSucceeded: number; + numFailed: number; + + @ViewChild('successMsg') + private successMsg: StringComponent; + + @ViewChild('errorMsg') + private errorMsg: StringComponent; + + constructor( + private modal: NgbModal, // required for passing to parent + private toast: ToastService, + private net: NetService, + private pcrud: PcrudService, + private evt: EventService, + private renderer: Renderer2, + private auth: AuthService) { + super(modal); // required for subclassing + } + + ngOnInit() {} + + async open(args: NgbModalOptions): Promise { + this.ids = [].concat(this.copyIds); + this.numSucceeded = 0; + this.numFailed = 0; + + await this.getNextCopy(); + setTimeout(() => + // Give the dialog a chance to render + this.renderer.selectRootElement('#new-barcode-input').focus() + ); + return super.open(args); + } + + async getNextCopy(): Promise { + + if (this.ids.length === 0) { + this.close(this.numSucceeded > 0); + return Promise.resolve(); + } + + this.newBarcode = ''; + + const id = this.ids.pop(); + + return this.pcrud.retrieve('acp', id) + .toPromise().then(c => this.copy = c); + } + + async replaceOneBarcode(): Promise { + this.barcodeExists = false; + + // First see if the barcode is in use + return this.pcrud.search('acp', {deleted: 'f', barcode: this.newBarcode}) + .toPromise().then(async (existing) => { + if (existing) { + this.barcodeExists = true; + return; + } + + this.copy.barcode(this.newBarcode); + this.pcrud.update(this.copy).toPromise().then( + async (ok) => { + this.numSucceeded++; + this.toast.success(await this.successMsg.current()); + this.getNextCopy(); + }, + async (err) => { + this.numFailed++; + console.error('Replace barcode failed: ', err); + this.toast.warning(await this.errorMsg.current()); + } + ) + }) + } +} + + +