From: Bill Erickson Date: Tue, 29 Jun 2021 21:54:13 +0000 (-0400) Subject: LPXXX Item Status Angular WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bd8b7f181059cb7be06f6792cd890c9335b8c086;p=working%2FEvergreen.git LPXXX Item Status Angular 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 index a9e31b1fb8..f1046892c4 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 @@ -9,12 +9,14 @@ import {ItemStatusComponent} from './status.component'; 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'; @NgModule({ declarations: [ MarkItemMissingPiecesComponent, ItemSummaryComponent, - ItemStatusComponent + ItemStatusComponent, + ItemRecentHistoryComponent ], imports: [ StaffCommonModule, diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/recent-history.component.html b/Open-ILS/src/eg2/src/app/staff/cat/item/recent-history.component.html new file mode 100644 index 0000000000..ddf0cee5a4 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/recent-history.component.html @@ -0,0 +1,62 @@ + +
+
+
+ No Previous Circ Group +
+
+
+
+
+
+ No Recent Circ Group +
+
+ + +
+
Total Circs
+
{{circInfo.totalCircs}}
+
+ +
+
Checkout Date
+
+ + {{circInfo.circSummary.start_time() | date:format.dateTimeFormat}} + +
+
+ +
+
Checkout Workstation
+
+ + {{circInfo.circSummary.checkout_workstation()}} + +
+
+ +
+
Last Renewed On
+
+ + {{circInfo.prevCircSummary.last_renewal_time() | date:format.dateTimeFormat}} + +
+
+ +
+
+
+ diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/recent-history.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/item/recent-history.component.ts new file mode 100644 index 0000000000..210f0006d4 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/recent-history.component.ts @@ -0,0 +1,63 @@ +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-recent-history', + templateUrl: 'recent-history.component.html' +}) + +export class ItemRecentHistoryComponent implements OnInit { + + @Input() item: IdlObject; + + loading = false; + circInfo: ItemCircInfo; + + @ViewChild('copyAlertsDialog') private copyAlertsDialog: CopyAlertsDialogComponent; + + 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.loadCircInfo() + .then(_ => this.loading = false); + } + + loadCircInfo(): Promise { + return this.circs.getItemCircInfo(this.item) + .then(info => this.circInfo = info); + } +} + + 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 d383d5ab21..ea75b82daa 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 @@ -38,6 +38,12 @@ +
  • + Recent Circ History + + + +
  • diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.html b/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.html index f6883172d5..012ef2a3a3 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.html @@ -47,8 +47,8 @@
    Due Date
    - - {{circ.due_date() | date:'shortDate'}} + + {{circInfo.currentCirc.due_date() | date:'shortDate'}}
    @@ -71,8 +71,8 @@
    Checkout Date
    - - {{circSummary.start_time() | date:'shortDate'}} + + {{circInfo.circSummary.start_time() | date:'shortDate'}}
    @@ -92,18 +92,18 @@
    Renewal Type
    - -
    OPAC
    -
    Desk
    -
    Phone
    -
    Automatic
    + +
    OPAC
    +
    Desk
    +
    Phone
    +
    Automatic
    Checkout Workstation
    - - {{circSummary.checkout_workstation()}} + + {{circInfo.circSummary.checkout_workstation()}}
    @@ -119,12 +119,12 @@
    Total Circs
    -
    {{total_circs}}
    +
    {{circInfo.totalCircs}}
    Duration Rule
    - - {{circ.duration_rule().name()}} + + {{circInfo.currentCirc.duration_rule().name()}}
    @@ -137,12 +137,12 @@
    Total Circs - Current Year
    -
    {{total_circs_this_year}}
    +
    {{circInfo.circsThisYear}}
    Recurring Fine Rule
    - - {{circ.recurring_fine_rule().name()}} + + {{circInfo.currentCirc.recurring_fine_rule().name()}}
    @@ -155,12 +155,12 @@
    Total Circs - Prev Year
    -
    {{total_circs_prev_year}}
    +
    {{circInfo.circsPrevYear}}
    Max Fine Rule
    - - {{circ.max_fine_rule().name()}} + + {{circInfo.currentCirc.max_fine_rule().name()}}
    @@ -177,9 +177,9 @@
    Checkin Time
    - - {{circ.checkin_time() || - circSummary.last_checkin_time() | date:'shortDate'}} + + {{circInfo.currentCirc.checkin_time() || + circInfo.circSummary.last_checkin_time() | date:'shortDate'}}
    @@ -190,23 +190,23 @@
    Renewal Workstation
    - - {{circSummary.last_renewal_workstation()}} + + {{circInfo.circSummary.last_renewal_workstation()}}
    Remaining Renewals
    - - {{circ.renewal_remaining()}} + + {{circInfo.currentCirc.renewal_remaining()}}
    Checkin Scan Time
    - - {{circ.checkin_scan_time() || - circSummary.last_checkin_scan_time() | date:'shortDate'}} + + {{circInfo.currentCirc.checkin_scan_time() || + circInfo.circSummary.last_checkin_scan_time() | date:'shortDate'}}
    @@ -235,13 +235,13 @@
    Checkin Workstation
    - - - {{circ.checkin_workstation().name()}} + + + {{circInfo.currentCirc.checkin_workstation().name()}} - {{circSummary.last_checkin_workstation().name()}} + *ngIf="!circInfo.currentCirc.checkin_workstation() && circInfo.circSummary.last_checkin_workstation()"> + {{circInfo.circSummary.last_checkin_workstation().name()}}
    @@ -272,7 +272,7 @@
    Item Alerts
    -
    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 721c803e5f..3b02cbf08d 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 @@ -12,7 +12,7 @@ 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} from '@eg/staff/share/circ/circ.service'; +import {CircService, ItemCircInfo} from '@eg/staff/share/circ/circ.service'; import {CopyAlertsDialogComponent } from '@eg/staff/share/holdings/copy-alerts-dialog.component'; @@ -25,12 +25,8 @@ export class ItemSummaryComponent implements OnInit { @Input() item: IdlObject; - circ: IdlObject; - circSummary: IdlObject; - prevCircSummary: IdlObject; - prevCircUser: IdlObject; - maxHistoryCount: number; loading = false; + circInfo: ItemCircInfo; @ViewChild('copyAlertsDialog') private copyAlertsDialog: CopyAlertsDialogComponent; @@ -57,53 +53,10 @@ export class ItemSummaryComponent implements OnInit { } loadCircInfo(): Promise { - - const copyOrg = - this.item.call_number().id() === -1 ? - this.item.circ_lib().id() : - this.item.call_number().owning_lib().id(); - - return this.perms.hasWorkPermAt(['VIEW_COPY_CHECKOUT_HISTORY'], copyOrg) - .then(hasPerm => { - if (hasPerm) { - return this.org.settings('circ.item_checkout_history.max') - .then(sets => { - this.maxHistoryCount = sets['circ.item_checkout_history.max'] || 4; - }); - } - }) - - .then(_ => this.circs.getLatestCirc(this.item.id())) - - .then(circ => { - this.circ = circ; - - if (!circ) { return Promise.resolve(); } - - return this.circs.getCircChain(this.circ.id()) - .then(summary => { - this.circSummary = summary; - - if (this.maxHistoryCount <= 1) { return; } - - return this.circs.getPrevCircChain(this.circ.id()) - .then(prevSummary => { - if (!prevSummary) { return; } - - this.prevCircSummary = prevSummary.summary; - - if (prevSummary.usr) { // aged circs have no 'usr'. - - return this.pcrud.retrieve('au', prevSummary.usr, - {flesh : 1, flesh_fields : {au : ['card']}}) - .toPromise().then(user => this.prevCircUser = user); - } - }); - }); - }); + return this.circs.getItemCircInfo(this.item) + .then(info => this.circInfo = info); } - addItemAlerts() { this.copyAlertsDialog.copyIds = [this.item.id()]; this.copyAlertsDialog.mode = 'create'; 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 ee56fed926..81bee2601f 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 @@ -15,6 +15,7 @@ import {StringService} from '@eg/share/string/string.service'; import {ServerStoreService} from '@eg/core/server-store.service'; import {HoldingsService} from '@eg/staff/share/holdings/holdings.service'; import {WorkLogService, WorkLogEntry} from '@eg/staff/share/worklog/worklog.service'; +import {PermService} from '@eg/core/perm.service'; export interface CircDisplayInfo { title?: string; @@ -196,6 +197,17 @@ export interface CheckinResult extends CircResultCommon { destCourierCode?: string; } +export interface ItemCircInfo { + maxHistoryCount: number; + circSummary?: IdlObject; + prevCircSummary?: IdlObject; + currentCirc?: IdlObject; + prevCircUser?: IdlObject; + totalCircs: number; + circsThisYear: number; + circsPrevYear: number; +} + @Injectable() export class CircService { static resultIndex = 0; @@ -220,6 +232,7 @@ export class CircService { private auth: AuthService, private holdings: HoldingsService, private worklog: WorkLogService, + private perms: PermService, private bib: BibRecordService ) {} @@ -1271,5 +1284,83 @@ export class CircService { return this.pcrud.search('aacs', {target_copy : copyId}, ops).toPromise(); } + + getItemCircInfo(item: IdlObject): Promise { + + const response: ItemCircInfo = { + maxHistoryCount: 0, + totalCircs: 0, + circsThisYear: 0, + 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() + + .then(counts => { + + const curYear = new Date().getFullYear(); + const prevYear = curYear - 1; + + counts.forEach(c => { + response.totalCircs += Number(c.count()); + if (c.year() === curYear) { + response.circsThisYear += Number(c.count()); + } + if (c.year() === prevYear) { + response.circsPrevYear += Number(c.count()); + } + }); + }) + .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(circ => { + + if (!circ) { return response; } + + response.currentCirc = circ; + + return this.getCircChain(circ.id()) + .then(summary => { + response.circSummary = summary; + + if (response.maxHistoryCount <= 1) { + return response; + } + + return this.getPrevCircChain(circ.id()) + .then(prevSummary => { + if (!prevSummary) { return response; } + + response.prevCircSummary = prevSummary.summary; + + if (prevSummary.usr) { // aged circs have no 'usr'. + + return this.pcrud.retrieve('au', prevSummary.usr, + {flesh : 1, flesh_fields : {au : ['card']}}) + .toPromise().then(user => response.prevCircUser = user); + } + }); + }); + }); + } } +