From: Bill Erickson Date: Wed, 14 Jul 2021 16:24:36 +0000 (-0400) Subject: LP1936233 Circ history list X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=170a1d555092c39b45823bada60a95d43887682d;p=working%2FEvergreen.git LP1936233 Circ history list Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/circ-history.component.html b/Open-ILS/src/eg2/src/app/staff/cat/item/circ-history.component.html new file mode 100644 index 0000000000..24eb48abb1 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/circ-history.component.html @@ -0,0 +1,2 @@ + +I have {{recentCircs.length}} recent circs diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/circ-history.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/item/circ-history.component.ts new file mode 100644 index 0000000000..c754936a69 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/circ-history.component.ts @@ -0,0 +1,57 @@ +import {Component, Input, OnInit, AfterViewInit, ViewChild} from '@angular/core'; +import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {IdlService, 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 {OrgService} from '@eg/core/org.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 {PermService} from '@eg/core/perm.service'; +import {PatronPenaltyDialogComponent} from '@eg/staff/share/patron/penalty-dialog.component'; +import {BarcodeSelectComponent} from '@eg/staff/share/barcodes/barcode-select.component'; +import {CatalogService} from '@eg/share/catalog/catalog.service'; +import {CircService, ItemCircInfo} from '@eg/staff/share/circ/circ.service'; +import {CopyAlertsDialogComponent + } from '@eg/staff/share/holdings/copy-alerts-dialog.component'; +import {FormatService} from '@eg/core/format.service'; + +@Component({ + selector: 'eg-item-circ-history', + templateUrl: 'circ-history.component.html' +}) + +export class ItemCircHistoryComponent implements OnInit { + + @Input() item: IdlObject; + recentCircs: IdlObject[] = []; + + loading = false; + + constructor( + private router: Router, + private route: ActivatedRoute, + private net: NetService, + private org: OrgService, + private printer: PrintService, + private pcrud: PcrudService, + private auth: AuthService, + private perms: PermService, + private idl: IdlService, + private evt: EventService, + private cat: CatalogService, + private holdings: HoldingsService, + private circs: CircService, + public format: FormatService + ) { } + + ngOnInit() { + this.loading = true; + this.circs.getRecentCircs(this.item) + .then(circs => this.recentCircs = circs) + .then(_ => this.loading = false); + } +} + + 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 index f1046892c4..5bad3bcc7b 100644 --- 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 @@ -10,13 +10,15 @@ import {BarcodesModule} from '@eg/staff/share/barcodes/barcodes.module'; import {CircModule} from '@eg/staff/share/circ/circ.module'; import {ItemSummaryComponent} from './summary.component'; import {ItemRecentHistoryComponent} from './recent-history.component'; +import {ItemCircHistoryComponent} from './circ-history.component'; @NgModule({ declarations: [ MarkItemMissingPiecesComponent, ItemSummaryComponent, ItemStatusComponent, - ItemRecentHistoryComponent + ItemRecentHistoryComponent, + ItemCircHistoryComponent ], imports: [ StaffCommonModule, 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 ea75b82daa..6a619b5bd8 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 @@ -44,6 +44,12 @@ +
  • + Circ History List + + + +
  • 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 6a996850f4..1bd5f2418a 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 @@ -1348,7 +1348,13 @@ export class CircService { ).toPromise(); } - getLatestCirc(copyId: number, ops?: PcrudQueryOps): Promise { + getLatestCirc(item: IdlObject, ops?: PcrudQueryOps): Promise { + return this.getRecentCircs(item, ops, 1) + .then(circs => circs[0]); + } + + getRecentCircs(item: IdlObject, + ops?: PcrudQueryOps, count?: number): Promise { if (!ops) { ops = { @@ -1368,9 +1374,35 @@ export class CircService { } ops.order_by = {aacs: 'xact_start desc'}; - ops.limit = 1; - return this.pcrud.search('aacs', {target_copy : copyId}, ops).toPromise(); + let promise = count ? + Promise.resolve(count) : this.getMaxCircDisplayCount(item); + + return promise.then(count => { + ops.limit = count; + return this.pcrud.search('aacs', + {target_copy : item.id()}, ops, {atomic: true}).toPromise(); + }); + } + + getMaxCircDisplayCount(item: IdlObject): Promise { + + const copyOrg: number = + item.call_number().id() === -1 ? + item.circ_lib().id() : + item.call_number().owning_lib().id(); + + return this.perms.hasWorkPermAt(['VIEW_COPY_CHECKOUT_HISTORY'], true) + .then(hasPerm => { + if (hasPerm['VIEW_COPY_CHECKOUT_HISTORY'].includes(copyOrg)) { + return this.org.settings('circ.item_checkout_history.max') + .then(sets => { + return sets['circ.item_checkout_history.max'] || 4; + }); + } else { + return 0; + } + }); } getItemCircInfo(item: IdlObject): Promise { @@ -1382,10 +1414,6 @@ export class CircService { circsPrevYear: 0 }; - const copyOrg: number = - item.call_number().id() === -1 ? - item.circ_lib().id() : - item.call_number().owning_lib().id(); return this.pcrud.search('circbyyr', {copy : item.id()}, null, {atomic : true}).toPromise() @@ -1405,20 +1433,9 @@ export class CircService { } }); }) - .then(_ => this.perms.hasWorkPermAt(['VIEW_COPY_CHECKOUT_HISTORY'], true)) - .then(hasPerm => { - if (hasPerm['VIEW_COPY_CHECKOUT_HISTORY'].includes(copyOrg)) { - return this.org.settings('circ.item_checkout_history.max') - .then(sets => { - response.maxHistoryCount = sets['circ.item_checkout_history.max'] || 4; - }); - } else { - response.maxHistoryCount = 0; - } - }) - - .then(_ => this.getLatestCirc(item.id())) - + .then(_ => this.getMaxCircDisplayCount(item)) + .then(count => response.maxHistoryCount = count) + .then(_ => this.getLatestCirc(item)) .then(circ => { if (!circ) { return response; }