From 716c0b650211efad753b13b9bce9328d8f4262e5 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 5 Apr 2021 17:55:37 -0400 Subject: [PATCH] LP1904036 adding patron to bucket; merging Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../src/app/staff/circ/patron/group.component.ts | 2 +- .../app/staff/circ/patron/patron.component.html | 4 +- .../eg2/src/app/staff/circ/patron/patron.module.ts | 2 - .../src/app/staff/circ/patron/patron.service.ts | 156 ++------------------- .../src/app/staff/circ/patron/resolver.service.ts | 3 - .../share/buckets/bucket-dialog.component.html | 3 + .../staff/share/buckets/bucket-dialog.component.ts | 5 +- .../staff/share/patron/merge-dialog.component.html | 51 +++++++ .../staff/share/patron/merge-dialog.component.ts | 84 +++++++++++ .../src/app/staff/share/patron/patron.module.ts | 6 + .../src/app/staff/share/patron/patron.service.ts | 147 ++++++++++++++++++- .../app/staff/share/patron/search.component.html | 12 ++ .../src/app/staff/share/patron/search.component.ts | 18 ++- .../{circ => share}/patron/summary.component.css | 0 .../{circ => share}/patron/summary.component.html | 92 ++++++------ .../{circ => share}/patron/summary.component.ts | 34 +++-- 16 files changed, 403 insertions(+), 216 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/share/patron/merge-dialog.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/share/patron/merge-dialog.component.ts rename Open-ILS/src/eg2/src/app/staff/{circ => share}/patron/summary.component.css (100%) rename Open-ILS/src/eg2/src/app/staff/{circ => share}/patron/summary.component.html (59%) rename Open-ILS/src/eg2/src/app/staff/{circ => share}/patron/summary.component.ts (73%) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/group.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/group.component.ts index 1221995c99..a4459c7e69 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/group.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/group.component.ts @@ -78,7 +78,7 @@ export class PatronGroupComponent implements OnInit { {authoritative: true}) .pipe(concatMap(u => { - const promise = this.context.getPatronVitalStats(u.id()) + const promise = this.patronService.getVitalStats(u.id()) .then(stats => { this.totalOwed += stats.fines.balance_owed; this.totalOut += stats.checkouts.total_out; diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html index 77507e7dce..bab79c3b2b 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html @@ -20,7 +20,9 @@
- + +
diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts index 77b421b25d..479f69b7fe 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts @@ -12,7 +12,6 @@ import {PatronModule} from '@eg/staff/share/patron/patron.module'; import {PatronContextService} from './patron.service'; import {PatronComponent} from './patron.component'; import {PatronAlertsComponent} from './alerts.component'; -import {SummaryComponent} from './summary.component'; import {CheckoutComponent} from './checkout.component'; import {HoldsComponent} from './holds.component'; import {EditComponent} from './edit.component'; @@ -36,7 +35,6 @@ import {PatronMessagesComponent} from './messages.component'; declarations: [ PatronComponent, PatronAlertsComponent, - SummaryComponent, CheckoutComponent, HoldsComponent, EditComponent, diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts index bb703bc6ed..e25a05bf1b 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts @@ -3,7 +3,8 @@ import {IdlObject} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; import {OrgService} from '@eg/core/org.service'; import {AuthService} from '@eg/core/auth.service'; -import {PatronService} from '@eg/staff/share/patron/patron.service'; +import {PatronService, PatronStats, PatronAlerts + } from '@eg/staff/share/patron/patron.service'; import {PatronSearch} from '@eg/staff/share/patron/search.component'; import {StoreService} from '@eg/core/store.service'; import {CircService, CircDisplayInfo} from '@eg/staff/share/circ/circ.service'; @@ -43,52 +44,6 @@ const PATRON_FLESH_FIELDS = [ 'groups' ]; -interface PatronStats { - fines: { - balance_owed: number, - group_balance_owed: number - }; - checkouts: { - overdue: number, - claims_returned: number, - lost: number, - out: number, - total_out: number, - long_overdue: number, - noncat: number - }; - holds: { - ready: number; - total: number; - }; -} - -export class PatronAlerts { - holdsReady = 0; - accountExpired = false; - accountExpiresSoon = false; - patronBarred = false; - patronInactive = false; - retrievedWithInactive = false; - invalidAddress = false; - alertMessage: string = null; - alertPenalties: IdlObject[] = []; - - hasAlerts(): boolean { - return ( - this.holdsReady > 0 || - this.accountExpired || - this.accountExpiresSoon || - this.patronBarred || - this.patronInactive || - this.retrievedWithInactive || - this.invalidAddress || - this.alertMessage !== null || - this.alertPenalties.length > 0 - ); - } -} - @Injectable() export class PatronContextService { @@ -96,9 +51,6 @@ export class PatronContextService { patronStats: PatronStats; alerts: PatronAlerts; - noTallyClaimsReturned = false; // circ.do_not_tally_claims_returned - tallyLost = false; // circ.tally_lost - loaded = false; lastPatronSearch: PatronSearch; @@ -111,16 +63,13 @@ export class PatronContextService { constructor( private store: StoreService, - private net: NetService, private org: OrgService, - private auth: AuthService, private circ: CircService, - public patronService: PatronService + public patrons: PatronService ) {} loadPatron(id: number): Promise { this.loaded = false; - this.patron = null; this.checkouts = []; return this.refreshPatron(id).then(_ => this.loaded = true); } @@ -131,45 +80,12 @@ export class PatronContextService { this.alerts = new PatronAlerts(); - return this.net.request( - 'open-ils.actor', - 'open-ils.actor.user.fleshed.retrieve', - this.auth.token(), id, PATRON_FLESH_FIELDS).toPromise() + return this.patrons.getFleshedById(id, PATRON_FLESH_FIELDS) .then(p => this.patron = p) .then(_ => this.getPatronStats(id)) .then(_ => this.compileAlerts()); } - getPatronVitalStats(id: number): Promise { - - return this.net.request( - 'open-ils.actor', - 'open-ils.actor.user.opac.vital_stats.authoritative', - this.auth.token(), id).toPromise() - - .then((stats: PatronStats) => { - - // force numeric values - stats.fines.balance_owed = Number(stats.fines.balance_owed); - - Object.keys(stats.checkouts).forEach(key => - stats.checkouts[key] = Number(stats.checkouts[key])); - - stats.checkouts.total_out = stats.checkouts.out + - stats.checkouts.overdue + stats.checkouts.long_overdue; - - if (!this.noTallyClaimsReturned) { - stats.checkouts.total_out += stats.checkouts.claims_returned; - } - - if (this.tallyLost) { - stats.checkouts.total_out += stats.checkouts.lost; - } - - return stats; - }); - } - getPatronStats(id: number): Promise { // When quickly navigating patron search results it's possible @@ -177,39 +93,8 @@ export class PatronContextService { // is called. Exit early instead of making an unneeded call. if (!this.patron) { return Promise.resolve(); } - return this.getPatronVitalStats(id) - - .then(stats => this.patronStats = stats) - - .then(_ => { - if (!this.patron) { return; } - - return this.net.request( - 'open-ils.circ', - 'open-ils.circ.open_non_cataloged_circulation.user.authoritative', - this.auth.token(), id - ).toPromise(); - - }).then(noncats => { - if (!this.patron) { return; } - - if (noncats && this.patronStats) { - this.patronStats.checkouts.noncat = noncats.length; - } - - return this.net.request( - 'open-ils.actor', - 'open-ils.actor.usergroup.members.balance_owed.authoritative', - this.auth.token(), this.patron.usrgroup() - ).toPromise(); - - }).then(fines => { - if (!this.patron) { return; } - - let total = 0; - fines.forEach(f => total += Number(f.balance_owed) * 100); - this.patronStats.fines.group_balance_owed = total / 100; - }); + return this.patrons.getVitalStats(this.patron) + .then(stats => this.patronStats = stats); } patronAlertsShown(): boolean { @@ -225,28 +110,15 @@ export class PatronContextService { // User navigated to a different patron mid-data load. if (!this.patron) { return Promise.resolve(); } - this.alerts.holdsReady = this.patronStats.holds.ready; - this.alerts.patronBarred = this.patron.barred() === 't'; - this.alerts.patronInactive = this.patron.active() === 'f'; - this.alerts.invalidAddress = this.patron.addresses() - .filter(a => a.valid() === 'f').length > 0; - this.alerts.alertMessage = this.patron.alert_message(); - this.alerts.alertPenalties = this.patron.standing_penalties() - .filter(p => p.standing_penalty().staff_alert() === 't'); - - if (this.searchBarcode) { - const card = this.patron.cards() - .filter(c => c.barcode() === this.searchBarcode)[0]; - this.alerts.retrievedWithInactive = card && card.active() === 'f'; - this.searchBarcode = null; - } + return this.patrons.compileAlerts(this.patron, this.patronStats) + .then(alerts => { + this.alerts = alerts; - return this.patronService.testExpire(this.patron) - .then(value => { - if (value === 'expired') { - this.alerts.accountExpired = true; - } else if (value === 'soon') { - this.alerts.accountExpiresSoon = true; + if (this.searchBarcode) { + const card = this.patron.cards() + .filter(c => c.barcode() === this.searchBarcode)[0]; + this.alerts.retrievedWithInactive = card && card.active() === 'f'; + this.searchBarcode = null; } }); } diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts index a781d55b85..db2787c252 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts @@ -130,9 +130,6 @@ export class PatronResolver implements Resolve> { 'ui.admin.patron_log.max_entries' ]).then(settings => { this.context.settingsCache = settings; - this.context.noTallyClaimsReturned = - settings['circ.do_not_tally_claims_returned']; - this.context.tallyLost = settings['circ.tally_lost']; }); } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/buckets/bucket-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/buckets/bucket-dialog.component.html index fcd885f751..f92f9d6c02 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/buckets/bucket-dialog.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/buckets/bucket-dialog.component.html @@ -1,3 +1,6 @@ + + +