--- /dev/null
+
+<b>I have {{recentCircs.length}} recent circs</b>
--- /dev/null
+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);
+ }
+}
+
+
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,
<eg-item-recent-history [item]="item"></eg-item-recent-history>
</ng-template>
</li>
+ <li ngbNavItem="circ-history">
+ <a ngbNavLink i18n>Circ History List</a>
+ <ng-template ngbNavContent>
+ <eg-item-circ-history [item]="item"></eg-item-circ-history>
+ </ng-template>
+ </li>
</ul>
<div [ngbNavOutlet]="itemNav"></div>
).toPromise();
}
- getLatestCirc(copyId: number, ops?: PcrudQueryOps): Promise<IdlObject> {
+ getLatestCirc(item: IdlObject, ops?: PcrudQueryOps): Promise<IdlObject> {
+ return this.getRecentCircs(item, ops, 1)
+ .then(circs => circs[0]);
+ }
+
+ getRecentCircs(item: IdlObject,
+ ops?: PcrudQueryOps, count?: number): Promise<IdlObject[]> {
if (!ops) {
ops = {
}
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<number> {
+
+ 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<ItemCircInfo> {
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(_ => 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; }