From: Bill Erickson Date: Mon, 2 Mar 2020 22:57:19 +0000 (-0500) Subject: LPXXX Missing pieces angular port WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fberick%2Flpxxx-item-missing-pieces-angular;p=working%2FEvergreen.git LPXXX Missing pieces angular port WIP Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/item.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/item/item.module.ts new file mode 100644 index 0000000000..9c501fbf8e --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/item.module.ts @@ -0,0 +1,24 @@ +import {NgModule} from '@angular/core'; +import {StaffCommonModule} from '@eg/staff/common.module'; +import {CommonWidgetsModule} from '@eg/share/common-widgets.module'; +import {ItemRoutingModule} from './routing.module'; +import {HoldingsModule} from '@eg/staff/share/holdings/holdings.module'; +import {PatronModule} from '@eg/staff/share/patron/patron.module'; +import {MarkItemMissingPiecesComponent} from './missing-pieces.component'; + +@NgModule({ + declarations: [ + MarkItemMissingPiecesComponent + ], + imports: [ + StaffCommonModule, + CommonWidgetsModule, + ItemRoutingModule, + HoldingsModule, + PatronModule + ], + providers: [ + ] +}) + +export class ItemModule {} diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/missing-pieces.component.html b/Open-ILS/src/eg2/src/app/staff/cat/item/missing-pieces.component.html new file mode 100644 index 0000000000..28e64ca173 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/missing-pieces.component.html @@ -0,0 +1,76 @@ + + + + + +
+
+
+
+ Barcode +
+ +
+ +
+
+ +
+
+
Title:
+
{{display('title')}}
+
+
+
Author:
+
{{display('author')}}
+
+
+
Call Number:
+
{{item.call_number().label()}}
+
+
+
+ + +
+
+
+ +
+
+
+ No circulation found for item with barcode {{itemBarcode}}. + Item not modified. +
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+
+
+ +
+
+
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/missing-pieces.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/item/missing-pieces.component.ts new file mode 100644 index 0000000000..e14f55b123 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/missing-pieces.component.ts @@ -0,0 +1,156 @@ +import {Component, Input, AfterViewInit, ViewChild, Renderer2} from '@angular/core'; +import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {IdlObject} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {AuthService} from '@eg/core/auth.service'; +import {NetService} from '@eg/core/net.service'; +import {PrintService} from '@eg/share/print/print.service'; +import {HoldingsService} from '@eg/staff/share/holdings/holdings.service'; +import {EventService} from '@eg/core/event.service'; +import {PatronPenaltyDialogComponent} from '@eg/staff/share/patron/penalty-dialog.component'; + +@Component({ + templateUrl: 'missing-pieces.component.html' +}) +export class MarkItemMissingPiecesComponent implements AfterViewInit { + + itemId: number; + itemBarcode: string; + item: IdlObject; + letter: string; + circNotFound = false; + processing = false; + + @ViewChild('penaltyDialog', {static: false}) + penaltyDialog: PatronPenaltyDialogComponent; + + constructor( + private route: ActivatedRoute, + private renderer: Renderer2, + private net: NetService, + private printer: PrintService, + private pcrud: PcrudService, + private auth: AuthService, + private evt: EventService, + private holdings: HoldingsService + ) { + this.itemId = +this.route.snapshot.paramMap.get('id'); + } + + ngAfterViewInit() { + if (this.itemId) { this.getItemById(); } + this.renderer.selectRootElement('#item-barcode-input').focus(); + } + + getItemByBarcode(): Promise { + this.itemId = null; + + if (!this.itemBarcode) { return Promise.resolve(); } + + return this.holdings.getItemIdFromBarcode(this.itemBarcode) + .then(id => { + this.itemId = id; + return this.getItemById(); + }); + } + + getItemById(): Promise { + this.circNotFound = false; + + if (!this.itemId) { return Promise.resolve(); } + + const flesh = { + flesh: 3, + flesh_fields: { + acp: ['call_number'], + acn: ['record'], + bre: ['flat_display_entries'] + } + }; + + return this.pcrud.retrieve('acp', this.itemId, flesh) + .toPromise().then(item => { + this.item = item; + this.itemId = item.id(); + this.itemBarcode = item.barcode(); + + }).then(_ => + setTimeout(() => + this.renderer.selectRootElement('#item-barcode-input').select()) + ); + } + + display(field: string): string { + if (!this.item) { return ''; } + + const entry = this.item.call_number().record() + .flat_display_entries() + .filter(fde => fde.name() === field)[0]; + + return entry ? entry.value() : ''; + } + + reset() { + this.item = null; + this.itemId = null; + this.itemBarcode = null; + this.circNotFound = false; + } + + processItem() { + this.circNotFound = false; + + if (!this.item) { return; } + + this.processing = true; + + this.net.request( + 'open-ils.circ', + 'open-ils.circ.mark_item_missing_pieces', + this.auth.token(), this.itemId + ).subscribe(resp => { + const evt = this.evt.parse(resp); // always returns event + this.processing = false; + + if (evt.textcode === 'ACTION_CIRCULATION_NOT_FOUND') { + this.circNotFound = true; + return; + } + + const payload = evt.payload; + + if (payload.letter) { + this.letter = payload.letter.template_output().data(); + } + + if (payload.slip) { + this.printer.print({ + printContext: 'default', + contentType: 'text/html', + text: payload.slip.template_output().data() + }); + } + + if (payload.circ) { + this.penaltyDialog.patronId = payload.circ.usr(); + this.penaltyDialog.open().subscribe( + penId => console.debug('Applied penalty ', penId)); + } + }); + } + + printLetter() { + this.printer.print({ + printContext: 'default', + contentType: 'text/plain', + text: this.letter + }); + } + + letterRowCount(): number { + return this.letter ? this.letter.split(/\n/).length + 2 : 20; + } +} + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/item/routing.module.ts new file mode 100644 index 0000000000..b3e775957b --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/routing.module.ts @@ -0,0 +1,20 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from '@angular/router'; +import {MarkItemMissingPiecesComponent} from './missing-pieces.component'; + +const routes: Routes = [{ + path: 'missing_pieces', + component: MarkItemMissingPiecesComponent + }, { + path: 'missing_pieces/:id', + component: MarkItemMissingPiecesComponent +}]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], + providers: [] +}) + +export class ItemRoutingModule {} +