From: Bill Erickson Date: Mon, 5 Apr 2021 21:55:37 +0000 (-0400) Subject: LP1904036 adding patron to bucket; merging X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=716c0b650211efad753b13b9bce9328d8f4262e5;p=evergreen%2Fpines.git LP1904036 adding patron to bucket; merging Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- 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/circ/patron/summary.component.css b/Open-ILS/src/eg2/src/app/staff/circ/patron/summary.component.css deleted file mode 100644 index 2c7d847f7d..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/summary.component.css +++ /dev/null @@ -1,6 +0,0 @@ - -.patron-summary-container .row:nth-child(odd):not(.alert) { - background-color: rgb(248, 248, 248); -} - - diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/summary.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/summary.component.html deleted file mode 100644 index 0a523dba64..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/summary.component.html +++ /dev/null @@ -1,205 +0,0 @@ - -
- -
-
-

- {{patron().family_name()}}, - {{patron().first_given_name()}} - {{patron().second_given_name()}} -

-
- -
account
-
-
- -
-
-

- {{patronService.namePart(patron(), 'family_name')}}, - {{patronService.namePart(patron(), 'first_given_name')}} - {{patronService.namePart(patron(), 'second_given_name')}} -

-
-
preferred
-
- -
-
- Patron account will expire soon. Please renew. -
-
- -
-
- {{pen.note() || pen.standing_penalty().label()}} -
-
{{pen.set_date() | date:'shortDate'}}
-
- -
-
Profile
-
{{patron().profile().name()}}
-
-
-
Home Library
-
{{context.orgSn(patron().home_ou())}}
-
-
-
Net Access
-
{{patron().net_access_level().name()}}
-
-
-
Date of Birth
-
{{patron().dob() | date:'shortDate'}}
-
-
-
Parent/Guardian
-
{{patron().guardian()}}
-
-
-
Last Activity
-
- - {{patron().usr_activity()[0].event_time() | date:'shortDate'}} - -
-
-
-
Last Updated
-
{{patron().last_update_time() | date:'shortDate'}}
-
-
-
Create Date
-
{{patron().create_date() | date:'shortDate'}}
-
-
-
Expire Date
-
{{patron().expire_date() | date:'shortDate'}}
-
- -
- - - -
-
Fines Owed
-
{{stats().fines.balance_owed | currency}}
-
- - -
-
Group Fines
-
{{stats().fines.group_balance_owed | currency}}
-
-
- -
-
Items Out
-
{{stats().checkouts.total_out}}
-
-
-
Overdue
-
{{stats().checkouts.overdue}}
-
-
-
Long Overdue
-
{{stats().checkouts.long_overdue}}
-
-
-
Claimed Returned
-
{{stats().checkouts.claims_returned}}
-
-
-
Lost
-
{{stats().checkouts.lost}}
-
-
-
Non-Cataloged
-
{{stats().checkouts.noncat}}
-
-
-
Holds
-
- {{stats().holds.ready}} / {{stats().holds.total}} -
-
- -
-
- -
-
Card
-
- {{patron().card() ? patron().card().barcode() : ''}} -
-
-
-
Username
-
{{patron().usrname()}}
-
-
-
Day Phone
-
{{patron().day_phone()}}
-
-
-
Evening Phone
-
{{patron().evening_phone()}}
-
-
-
Other Phone
-
{{patron().other_phone()}}
-
-
-
ID1
-
{{patron().ident_value()}}
-
-
-
ID2
-
{{patron().ident_value2()}}
-
-
-
Email
-
- - {{patron().email()}} -
-
- -
- -
-
-
- -
{{addr.address_type()}}
-
- copy - print -
-
-
{{addr.street1()}} {{addr.street2()}}
-
{{addr.city()}}, {{addr.state()}} {{addr.post_code()}}
-
- - - -
-
-
diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/summary.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/summary.component.ts deleted file mode 100644 index 119e1cf648..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/summary.component.ts +++ /dev/null @@ -1,80 +0,0 @@ -import {Component, OnInit, Input} from '@angular/core'; -import {Router, ActivatedRoute, ParamMap} from '@angular/router'; -import {NgbNav, NgbNavChangeEvent} from '@ng-bootstrap/ng-bootstrap'; -import {OrgService} from '@eg/core/org.service'; -import {IdlObject} from '@eg/core/idl.service'; -import {NetService} from '@eg/core/net.service'; -import {PatronService} from '@eg/staff/share/patron/patron.service'; -import {PatronContextService} from './patron.service'; -import {PrintService} from '@eg/share/print/print.service'; - -@Component({ - templateUrl: 'summary.component.html', - styleUrls: ['summary.component.css'], - selector: 'eg-patron-summary' -}) -export class SummaryComponent implements OnInit { - - constructor( - private org: OrgService, - private net: NetService, - private printer: PrintService, - public patronService: PatronService, - public context: PatronContextService - ) {} - - ngOnInit() { - } - - patron(): IdlObject { - return this.context.patron; - } - - stats(): any { - return this.context.patronStats; - } - - hasPrefName(): boolean { - if (this.patron()) { - return ( - this.patron().pref_first_given_name() || - this.patron().pref_second_given_name() || - this.patron().pref_family_name() - ); - } - } - - printAddress(addr: IdlObject) { - this.printer.print({ - templateName: 'patron_address', - contextData: { - patron: this.context.patron, - address: addr - }, - printContext: 'default' - }); - } - - copyAddress(addr: IdlObject) { - // Note navigator.clipboard requires special permissions. - // This is hinky, but gets the job done without the perms. - - const node = document.getElementById( - `patron-address-copy-${addr.id()}`) as HTMLTextAreaElement; - - // Un-hide the textarea just long enough to copy its data. - // Using node.style instead of *ngIf in hopes it - // will be quicker, so the user never sees the textarea. - node.style.visibility = 'visible'; - node.focus(); - node.select(); - - if (!document.execCommand('copy')) { - console.error('Copy command failed'); - } - - node.style.visibility = 'hidden'; - } - -} - 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 @@ + + +