From 4e25ce0b5700c5611abf8305b9bbf97f49b4c31b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 22 Apr 2021 12:00:45 -0400 Subject: [PATCH] LP1904036 work log continued Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../eg2/src/app/staff/catalog/catalog.module.ts | 4 ++- .../src/app/staff/catalog/hold/hold.component.html | 1 + .../src/app/staff/catalog/hold/hold.component.ts | 13 +++++++-- .../src/app/staff/circ/patron/bills.component.ts | 8 +++++ .../app/staff/circ/patron/checkout.component.ts | 6 +++- .../staff/circ/patron/edit-toolbar.component.ts | 8 ++--- .../src/app/staff/circ/patron/edit.component.ts | 10 ++++++- .../app/staff/circ/patron/patron.component.html | 1 + .../eg2/src/app/staff/circ/patron/patron.module.ts | 4 ++- .../app/staff/circ/patron/register.component.html | 2 ++ .../src/app/staff/share/billing/billing.service.ts | 1 - .../eg2/src/app/staff/share/circ/circ.module.ts | 8 ++--- .../eg2/src/app/staff/share/circ/circ.service.ts | 16 ++++++---- .../app/staff/share/circ/components.component.html | 10 ------- .../app/staff/share/circ/components.component.ts | 16 +--------- .../app/staff/share/worklog/strings.component.html | 11 +++++++ .../app/staff/share/worklog/strings.component.ts | 32 ++++++++++++++++++++ .../src/app/staff/share/worklog/worklog.module.ts | 21 +++++++++++++ .../worklog.service.ts} | 34 ++++++++++------------ 19 files changed, 140 insertions(+), 66 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/share/worklog/strings.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/share/worklog/strings.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/share/worklog/worklog.module.ts rename Open-ILS/src/eg2/src/app/staff/share/{circ/work-log.service.ts => worklog/worklog.service.ts} (65%) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts index 58781da2c1..77d19ca41c 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts @@ -36,6 +36,7 @@ import {PreferencesComponent} from './prefs.component'; import {BrowsePagerComponent} from './result/browse-pager.component'; import {HttpClientModule} from '@angular/common/http'; import {BarcodesModule} from '@eg/staff/share/barcodes/barcodes.module'; +import {WorkLogModule} from '@eg/staff/share/worklog/worklog.module'; @NgModule({ declarations: [ @@ -76,7 +77,8 @@ import {BarcodesModule} from '@eg/staff/share/barcodes/barcodes.module'; PatronModule, MarcEditModule, HttpClientModule - BarcodesModule + BarcodesModule, + WorkLogModule ], providers: [ StaffCatalogService diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html index c04c970dfb..b374fbf19b 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html @@ -1,6 +1,7 @@ + this.worklog.loadSettings()); this.org.list().forEach(org => { if (org.ou_type().can_have_vols() === 'f') { @@ -638,6 +640,13 @@ export class HoldComponent implements OnInit { if (request.result.success) { ctx.success = true; + this.worklog.record({ + action: 'requested_hold', + hold_id: request.result.holdId, + patron_id: this.user.id(), + user: this.user.family_name() + }); + // Overrides are processed one hold at a time, so // we have to invoke the post-holds logic here // instead of the batch placeHolds() method. If diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts index b9ff5dbdf9..d38210fef6 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts @@ -27,6 +27,7 @@ import {AddBillingDialogComponent} from '@eg/staff/share/billing/billing-dialog. import {AudioService} from '@eg/share/util/audio.service'; import {ToastService} from '@eg/share/toast/toast.service'; import {GridFlatDataService} from '@eg/share/grid/grid-flat-data.service'; +import {WorkLogService} from '@eg/staff/share/worklog/worklog.service'; @Component({ templateUrl: 'bills.component.html', @@ -84,6 +85,7 @@ export class BillsComponent implements OnInit, AfterViewInit { private circ: CircService, private billing: BillingService, private flatData: GridFlatDataService, + private worklog: WorkLogService, public patronService: PatronService, public context: PatronContextService ) {} @@ -270,6 +272,12 @@ export class BillsComponent implements OnInit, AfterViewInit { ); }) .then(resp => { + this.worklog.record({ + user: this.patron().family_name(), + patron_id: this.patron().id(), + amount: this.pendingPayment(), + action: 'paid_bill' + }); this.patron().last_xact_id(resp.last_xact_id); return this.handlePayReceipt(payments, resp.payments); }) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.ts index e0603442cf..ee90e0cfa9 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.ts @@ -91,7 +91,11 @@ export class CheckoutComponent implements OnInit, AfterViewInit { collectParams(): Promise { const params: CheckoutParams = { - patron_id: this.context.summary.id + patron_id: this.context.summary.id, + _worklog: { + user: this.context.summary.patron.family_name(), + patron_id: this.context.summary.id + } }; if (this.checkoutNoncat) { diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.ts index fc1093bcc5..f67751fb0d 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit-toolbar.component.ts @@ -6,7 +6,6 @@ import {IdlService, IdlObject} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; import {AuthService} from '@eg/core/auth.service'; import {PatronService} from '@eg/staff/share/patron/patron.service'; -import {PatronContextService} from './patron.service'; import {PatronSearchFieldSet} from '@eg/staff/share/patron/search.component'; export enum VisibilityLevel { @@ -49,8 +48,7 @@ export class EditToolbarComponent implements OnInit { private idl: IdlService, private net: NetService, private auth: AuthService, - private patronService: PatronService, - public context: PatronContextService + private patronService: PatronService ) {} ngOnInit() { @@ -87,9 +85,9 @@ export class EditToolbarComponent implements OnInit { }); } - checkAddressAlerts(addr: IdlObject) { + checkAddressAlerts(patron: IdlObject, addr: IdlObject) { const addrHash = this.idl.toHash(addr); - const patron = this.context.summary.patron; + console.log('CHECKING ADDR', addrHash); addrHash.mailing_address = addr.id() === patron.mailing_address().id(); addrHash.billing_address = addr.id() === patron.billing_address().id(); this.net.request( diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts index 37c9bf3ac1..3b1576d28a 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts @@ -25,6 +25,7 @@ import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; import {HoldNotifyUpdateDialogComponent} from './hold-notify-update.component'; import {BroadcastService} from '@eg/share/util/broadcast.service'; import {PrintService} from '@eg/share/print/print.service'; +import {WorkLogService} from '@eg/staff/share/worklog/worklog.service'; const PATRON_FLESH_FIELDS = [ 'cards', @@ -224,6 +225,7 @@ export class EditComponent implements OnInit, AfterViewInit { private broadcaster: BroadcastService, private patronService: PatronService, private printer: PrintService, + private worklog: WorkLogService, public context: PatronContextService ) {} @@ -908,7 +910,7 @@ export class EditComponent implements OnInit, AfterViewInit { case 'city': // dupe search on address wants the address object as the value. this.dupeValueChange('address', obj); - this.toolbar.checkAddressAlerts(obj); + this.toolbar.checkAddressAlerts(this.patron, obj); break; case 'post_code': @@ -1351,6 +1353,12 @@ export class EditComponent implements OnInit, AfterViewInit { postSaveRedirect(clone: boolean) { + this.worklog.record({ + user: this.modifiedPatron.family_name(), + patron_id: this.modifiedPatron.id(), + action: this.patron.isnew() ? 'registered_patron' : 'edited_patron' + }); + if (this.stageUser) { this.broadcaster.broadcast('eg.pending_usr.update', {usr: this.idl.toHash(this.modifiedPatron)}); 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 fb676fb16e..f2c2aa7038 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 @@ -50,6 +50,7 @@ +
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 0417d3eb9d..2d7d490023 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 @@ -32,6 +32,7 @@ import {HoldNotifyUpdateDialogComponent} from './hold-notify-update.component'; import {PatronMessagesComponent} from './messages.component'; import {PatronPermsComponent} from './perms.component'; import {BillingHistoryComponent} from './billing-history.component'; +import {WorkLogModule} from '@eg/staff/share/worklog/worklog.module'; @NgModule({ declarations: [ @@ -67,7 +68,8 @@ import {BillingHistoryComponent} from './billing-history.component'; BookingModule, PatronModule, PatronRoutingModule, - BarcodesModule + BarcodesModule, + WorkLogModule ], providers: [ PatronResolver, diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/register.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/register.component.html index f78b25a595..57f3229157 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/register.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/register.component.html @@ -1,6 +1,8 @@ + +
diff --git a/Open-ILS/src/eg2/src/app/staff/share/billing/billing.service.ts b/Open-ILS/src/eg2/src/app/staff/share/billing/billing.service.ts index 884eba2417..0d6527334e 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/billing/billing.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/billing/billing.service.ts @@ -101,7 +101,6 @@ export class BillingService { return Promise.reject(evt); } - // TODO work log return response; }); } diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/circ.module.ts b/Open-ILS/src/eg2/src/app/staff/share/circ/circ.module.ts index 8a3602b72e..fef714aee4 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/circ.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/circ.module.ts @@ -14,7 +14,7 @@ import {RouteDialogComponent} from './route-dialog.component'; import {CopyInTransitDialogComponent} from './in-transit-dialog.component'; import {CancelTransitDialogComponent} from './cancel-transit-dialog.component'; import {BackdateDialogComponent} from './backdate-dialog.component'; -import {WorkLogService} from './work-log.service'; +import {WorkLogModule} from '@eg/staff/share/worklog/worklog.module'; @NgModule({ declarations: [ @@ -33,7 +33,8 @@ import {WorkLogService} from './work-log.service'; imports: [ StaffCommonModule, HoldingsModule, - BillingModule + BillingModule, + WorkLogModule ], exports: [ CircGridComponent, @@ -42,8 +43,7 @@ import {WorkLogService} from './work-log.service'; CircComponentsComponent ], providers: [ - CircService, - WorkLogService + CircService ] }) 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 6dcbcefece..3d4d453f95 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 @@ -14,7 +14,7 @@ import {CircComponentsComponent} from './components.component'; 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 './work-log.service'; +import {WorkLogService, WorkLogEntry} from '@eg/staff/share/worklog/worklog.service'; export interface CircDisplayInfo { title?: string; @@ -130,6 +130,7 @@ export interface CheckoutParams { // internal tracking _override?: boolean; _renewal?: boolean; + _worklog?: WorkLogEntry; } export interface CircResultCommon { @@ -175,6 +176,7 @@ export interface CheckinParams { // internal / local values that are moved from the API request. _override?: boolean; + _worklog?: WorkLogEntry; } export interface CheckinResult extends CircResultCommon { @@ -429,7 +431,9 @@ export class CircService { result.nonCatCirc = payload.noncat_circ; return this.fleshCommonData(result).then(_ => { - this.addWorkLog(params._renewal ? 'renewal' : 'checkout', result); + const action = params._renewal ? 'renewal' : + (params.noncat ? 'noncat_checkout' : 'checkout'); + this.addWorkLog(action, result); return result; }); } @@ -843,12 +847,14 @@ export class CircService { } addWorkLog(action: string, result: CircResultCommon) { - const entry: WorkLogEntry = {action: action}; - const params = result.params; const copy = result.copy; const patron = result.patron; + // Some worklog data may be provided by the caller in the params. + const entry: WorkLogEntry = + Object.assign(params._worklog || {}, {action: action}); + if (copy) { entry.item = copy.barcode(); entry.item_id = copy.id(); @@ -860,8 +866,6 @@ export class CircService { if (patron) { entry.patron_id = patron.id(); entry.user = patron.family_name(); - } else { - entry.patron_id = (params as CheckoutParams).patron_id; } if (result.hold) { diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/components.component.html b/Open-ILS/src/eg2/src/app/staff/share/circ/components.component.html index 54bb765289..a937b4bb64 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/components.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/components.component.html @@ -61,13 +61,3 @@ - - - - - - - - - - diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/components.component.ts b/Open-ILS/src/eg2/src/app/staff/share/circ/components.component.ts index 5b9a51c966..76dc5f5aab 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/components.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/components.component.ts @@ -9,7 +9,6 @@ import {RouteDialogComponent} from './route-dialog.component'; import {CopyInTransitDialogComponent} from './in-transit-dialog.component'; import {CopyAlertManagerDialogComponent } from '@eg/staff/share/holdings/copy-alert-manager.component'; -import {WorkLogService, WorkLogEntry} from './work-log.service'; /* Container component for sub-components used by circulation actions. * @@ -38,21 +37,8 @@ export class CircComponentsComponent { @ViewChild('holdShelfStr') holdShelfStr: StringComponent; @ViewChild('catalogingStr') catalogingStr: StringComponent; - // Worklog string variable names have to match "worklog_{{action}}" - @ViewChild('worklog_checkout') worklog_checkout: StringComponent; - @ViewChild('worklog_checkin') worklog_checkin: StringComponent; - @ViewChild('worklog_noncat_checkout') worklog_noncat_checkout: StringComponent; - @ViewChild('worklog_renew') worklog_renew: StringComponent; - @ViewChild('worklog_requested_hold') worklog_requested_hold: StringComponent; - @ViewChild('worklog_edited_patron') worklog_edited_patron: StringComponent; - @ViewChild('worklog_registered_patron') worklog_registered_patron: StringComponent; - @ViewChild('worklog_paid_bill') worklog_paid_bill: StringComponent; - - constructor( - private worklog: WorkLogService, - private circ: CircService) { + constructor(private circ: CircService) { this.circ.components = this; - this.worklog.components = this; } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/worklog/strings.component.html b/Open-ILS/src/eg2/src/app/staff/share/worklog/strings.component.html new file mode 100644 index 0000000000..9a09918809 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/worklog/strings.component.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/worklog/strings.component.ts b/Open-ILS/src/eg2/src/app/staff/share/worklog/strings.component.ts new file mode 100644 index 0000000000..f824293d1e --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/worklog/strings.component.ts @@ -0,0 +1,32 @@ +import {Component, OnInit, Output, Input, ViewChild, EventEmitter} from '@angular/core'; +import {StringComponent} from '@eg/share/string/string.component'; +import {WorkLogService, WorkLogEntry} from './worklog.service'; + +/** Component for housing strings related to the worklog service + * + * NOTE: once we have in-code i18n support, this and our module + * can go away, leaving only the service + */ + + +@Component({ + templateUrl: 'strings.component.html', + selector: 'eg-worklog-strings-components' +}) +export class WorkLogStringsComponent { + + // Worklog string variable names have to match "worklog_{{action}}" + @ViewChild('worklog_checkout') worklog_checkout: StringComponent; + @ViewChild('worklog_checkin') worklog_checkin: StringComponent; + @ViewChild('worklog_noncat_checkout') worklog_noncat_checkout: StringComponent; + @ViewChild('worklog_renew') worklog_renew: StringComponent; + @ViewChild('worklog_requested_hold') worklog_requested_hold: StringComponent; + @ViewChild('worklog_edited_patron') worklog_edited_patron: StringComponent; + @ViewChild('worklog_registered_patron') worklog_registered_patron: StringComponent; + @ViewChild('worklog_paid_bill') worklog_paid_bill: StringComponent; + + constructor(private worklog: WorkLogService) { + this.worklog.workLogStrings = this; + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/share/worklog/worklog.module.ts b/Open-ILS/src/eg2/src/app/staff/share/worklog/worklog.module.ts new file mode 100644 index 0000000000..c6c61dfe81 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/worklog/worklog.module.ts @@ -0,0 +1,21 @@ +import {NgModule} from '@angular/core'; +import {StaffCommonModule} from '@eg/staff/common.module'; +import {WorkLogService} from './worklog.service'; +import {WorkLogStringsComponent} from './strings.component'; + +@NgModule({ + declarations: [ + WorkLogStringsComponent + ], + imports: [ + StaffCommonModule + ], + exports: [ + WorkLogStringsComponent + ], + providers: [ + WorkLogService + ] +}) + +export class WorkLogModule {} diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/work-log.service.ts b/Open-ILS/src/eg2/src/app/staff/share/worklog/worklog.service.ts similarity index 65% rename from Open-ILS/src/eg2/src/app/staff/share/circ/work-log.service.ts rename to Open-ILS/src/eg2/src/app/staff/share/worklog/worklog.service.ts index 724b0fbc45..5d284d343a 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/work-log.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/worklog/worklog.service.ts @@ -1,20 +1,9 @@ import {Injectable} from '@angular/core'; -import {Observable, empty, from} from 'rxjs'; -import {map, concatMap, mergeMap} from 'rxjs/operators'; -import {IdlObject} from '@eg/core/idl.service'; -import {NetService} from '@eg/core/net.service'; -import {OrgService} from '@eg/core/org.service'; -import {PcrudService} from '@eg/core/pcrud.service'; -import {EventService, EgEvent} from '@eg/core/event.service'; import {AuthService} from '@eg/core/auth.service'; -import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service'; -import {AudioService} from '@eg/share/util/audio.service'; -import {CircEventsComponent} from './events-dialog.component'; -import {CircComponentsComponent} from './components.component'; import {StringService} from '@eg/share/string/string.service'; import {ServerStoreService} from '@eg/core/server-store.service'; import {StoreService} from '@eg/core/store.service'; -import {HoldingsService} from '@eg/staff/share/holdings/holdings.service'; +import {WorkLogStringsComponent} from './strings.component'; export interface WorkLogEntry { when?: Date; @@ -35,7 +24,7 @@ export class WorkLogService { maxEntries: number = null; maxPatrons: number = null; - components: CircComponentsComponent; + workLogStrings: WorkLogStringsComponent = null; constructor( private store: StoreService, @@ -60,20 +49,27 @@ export class WorkLogService { return; } + if (this.workLogStrings === null) { + throw new Error( + 'Add to your component for worklog support'); + return; + } + entry.when = new Date(); entry.actor = this.auth.user().usrname(); - entry.msg = this.components[`worklog_${entry.action}`].text; + entry.msg = this.workLogStrings[`worklog_${entry.action}`].text; - const workLog = this.store.getLocalItem('eg.work_log') || []; - let patronLog = this.store.getLocalItem('eg.patron_log') || []; + const workLog: WorkLogEntry[] = + this.store.getLocalItem('eg.work_log') || []; + + let patronLog: WorkLogEntry[] = + this.store.getLocalItem('eg.patron_log') || []; workLog.push(entry); - if (workLog.lenth > this.maxEntries) { + if (workLog.length > this.maxEntries) { workLog.shift(); } - console.log('HERE', workLog); - this.store.setLocalItem('eg.work_log', workLog); if (entry.patron_id) { -- 2.11.0