From 98a1b6453c0d29785c1c8e19b7c62354e83abfe5 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 21 Jun 2021 17:51:10 -0400 Subject: [PATCH] LPXXX Item Status Angular WIP Signed-off-by: Bill Erickson --- .../src/app/staff/cat/item/status.component.html | 1 - .../eg2/src/app/staff/cat/item/status.component.ts | 12 +++---- .../src/app/staff/cat/item/summary.component.ts | 42 ++++++---------------- .../eg2/src/app/staff/share/circ/circ.service.ts | 27 +++++++++++++- 4 files changed, 43 insertions(+), 39 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.html b/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.html index b44b31569a..d383d5ab21 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.html @@ -3,7 +3,6 @@ -
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.ts index 65b8a64a1c..7764ba1179 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.ts @@ -109,7 +109,7 @@ export class ItemStatusComponent implements OnInit, AfterViewInit { } else { this.itemBarcode = null; - if (this.tab == 'list') { + if (this.tab === 'list') { this.selectInput(); return this.getItemById(res.id); } else { @@ -133,18 +133,18 @@ export class ItemStatusComponent implements OnInit, AfterViewInit { flesh : 4, flesh_fields : { acp : [ - 'call_number','location','status','floating','circ_modifier', - 'age_protect','circ_lib','copy_alerts', 'creator', + 'call_number', 'location', 'status', 'floating', 'circ_modifier', + 'age_protect', 'circ_lib', 'copy_alerts', 'creator', 'editor', 'circ_as_type', 'latest_inventory', 'floating' ], - acn : ['record','prefix','suffix','label_class', 'owning_lib'], - bre : ['simple_record','creator','editor'], + acn : ['record', 'prefix', 'suffix', 'label_class', 'owning_lib'], + bre : ['simple_record', 'creator', 'editor'], alci : ['inventory_workstation'] }, select : { // avoid fleshing MARC on the bre // note: don't add simple_record.. not sure why - bre : ['id','tcn_value','creator','editor', 'create_date', 'edit_date'], + bre : ['id', 'tcn_value', 'creator', 'editor', 'create_date', 'edit_date'], } }; diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.ts index 41cc81ccca..721c803e5f 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.ts @@ -59,7 +59,7 @@ export class ItemSummaryComponent implements OnInit { loadCircInfo(): Promise { const copyOrg = - this.item.call_number().id() == -1 ? + this.item.call_number().id() === -1 ? this.item.circ_lib().id() : this.item.call_number().owning_lib().id(); @@ -69,52 +69,32 @@ export class ItemSummaryComponent implements OnInit { return this.org.settings('circ.item_checkout_history.max') .then(sets => { this.maxHistoryCount = sets['circ.item_checkout_history.max'] || 4; - }) + }); } }) - .then(_ => { - - return this.pcrud.search('aacs', - {target_copy : this.item.id()}, - { flesh: 2, - flesh_fields: { - aacs: [ - 'usr', - 'workstation', - 'checkin_workstation', - 'duration_rule', - 'max_fine_rule', - 'recurring_fine_rule' - ], - au: ['card'] - }, - order_by: {aacs: 'xact_start desc'}, - limit: 1 - } - - ).toPromise(); - }) + + .then(_ => this.circs.getLatestCirc(this.item.id())) .then(circ => { this.circ = circ; - if (!circ) return Promise.resolve(); + if (!circ) { return Promise.resolve(); } return this.circs.getCircChain(this.circ.id()) .then(summary => { - this.circSummary = summary + this.circSummary = summary; if (this.maxHistoryCount <= 1) { return; } return this.circs.getPrevCircChain(this.circ.id()) - .then(summary => { - if (!summary) { return; } + .then(prevSummary => { + if (!prevSummary) { return; } - this.prevCircSummary = summary.summary; + this.prevCircSummary = prevSummary.summary; - if (summary.usr) { // aged circs have no 'usr'. + if (prevSummary.usr) { // aged circs have no 'usr'. - return this.pcrud.retrieve('au', summary.usr, + return this.pcrud.retrieve('au', prevSummary.usr, {flesh : 1, flesh_fields : {au : ['card']}}) .toPromise().then(user => this.prevCircUser = user); } diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts b/Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts index 882a808f0e..ee56fed926 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts @@ -4,7 +4,7 @@ import {map, concatMap, mergeMap} from 'rxjs/operators'; import {IdlObject} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; import {OrgService} from '@eg/core/org.service'; -import {PcrudService} from '@eg/core/pcrud.service'; +import {PcrudService, PcrudQueryOps} from '@eg/core/pcrud.service'; import {EventService, EgEvent} from '@eg/core/event.service'; import {AuthService} from '@eg/core/auth.service'; import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service'; @@ -1246,5 +1246,30 @@ export class CircService { ).toPromise(); } + + getLatestCirc(copyId: number, ops?: PcrudQueryOps): Promise { + + if (!ops) { + ops = { + flesh: 2, + flesh_fields: { + aacs: [ + 'usr', + 'workstation', + 'checkin_workstation', + 'duration_rule', + 'max_fine_rule', + 'recurring_fine_rule' + ], + au: ['card'] + } + }; + } + + ops.order_by = {aacs: 'xact_start desc'}; + ops.limit = 1; + + return this.pcrud.search('aacs', {target_copy : copyId}, ops).toPromise(); + } } -- 2.11.0