From bed5c4093c434b9ddb88b84af4ec74daffb00a90 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 1 Apr 2021 15:41:11 -0400 Subject: [PATCH] LP1904036 Hold notify mods Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../src/app/staff/circ/patron/edit.component.ts | 13 +----- .../circ/patron/hold-notify-update.component.html | 46 +++++++++++++++------- .../circ/patron/hold-notify-update.component.ts | 44 +++++++++++++++++---- 3 files changed, 71 insertions(+), 32 deletions(-) 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 03c1b7ad5d..31635ab0c3 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 @@ -1285,18 +1285,9 @@ export class EditComponent implements OnInit, AfterViewInit { if (mods.length === 0) { return Promise.resolve(); } - console.log('HOLD NOTIFY MODS', mods); - - this.holdNotifyUpdateDialog.smsCarriers = this.smsCarriers; + this.holdNotifyUpdateDialog.patronId = this.patronId; this.holdNotifyUpdateDialog.mods = mods; - - this.holdNotifyUpdateDialog.defaultSms = - this.userSettings['opac.default_sms_notify'] - || this.holdNotifyValues.default_sms; - - this.holdNotifyUpdateDialog.defaultPhone = - this.userSettings['opac.default_phone'] - || this.holdNotifyValues.default_phone; + this.holdNotifyUpdateDialog.smsCarriers = this.smsCarriers; this.holdNotifyUpdateDialog.defaultCarrier = this.userSettings['opac.default_sms_carrier'] diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/hold-notify-update.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/hold-notify-update.component.html index 45d7684f50..ed7fbeccbd 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/hold-notify-update.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/hold-notify-update.component.html @@ -11,16 +11,27 @@
- You have set Notify by Phone to - You have set Notify by SMS to - You have set Notify by Email to - You have set Default Phone Number to - You have set Default SMS/Text Number to - -
- -
- You have set Default SMS Carrier to {{carrierName(mod.newValue)}} + + You have set Notify by Phone to + + + + You have set Notify by SMS to + + + + You have set Notify by Email to + + + + You have set Default Phone Number to {{mod.newValue}} + + + You have set Default SMS/Text Number to {{mod.newValue}} + + + You have set Default SMS Carrier to {{carrierName(mod.newValue)}} +
@@ -47,9 +58,16 @@
diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/hold-notify-update.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/hold-notify-update.component.ts index 742d76af15..d8a3544a0e 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/hold-notify-update.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/hold-notify-update.component.ts @@ -1,6 +1,6 @@ import {Component, OnInit, Input, ViewChild} from '@angular/core'; -import {Observable, empty} from 'rxjs'; -import {switchMap, tap} from 'rxjs/operators'; +import {Observable, from, empty} from 'rxjs'; +import {filter, concatMap, switchMap, tap} from 'rxjs/operators'; import {IdlObject, IdlService} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; import {EventService} from '@eg/core/event.service'; @@ -31,13 +31,13 @@ export class HoldNotifyUpdateDialogComponent extends DialogComponent implements OnInit { // Values provided directly by our parent component + patronId: number; smsCarriers: ComboboxEntry[]; mods: HoldNotifyMod[] = []; - defaultSms: string; - defaultPhone: string; defaultCarrier: number; selected: {[field: string]: boolean} = {}; + loading = false; constructor( private modal: NgbModal, @@ -51,9 +51,6 @@ export class HoldNotifyUpdateDialogComponent super(modal); } - applyChanges() { - } - isPhoneChange(mod: HoldNotifyMod): boolean { return mod.field.match(/_phone/) !== null; } @@ -70,6 +67,39 @@ export class HoldNotifyUpdateDialogComponent const entry = this.smsCarriers.filter(e => e.id === id)[0]; return entry ? entry.label : ''; } + + anySelected(): boolean { + return Object.values(this.selected).filter(v => v).length > 0; + } + + applyChanges() { + this.loading = true; + + from(Object.keys(this.selected)) + .pipe(filter(field => this.selected[field] === true)) + .pipe(concatMap(field => { + + const mod = this.mods.filter(m => m.field === field)[0]; + const holdIds = mod.holds.map(h => h.id); + const carrierId = mod.field === 'default_sms' ? this.defaultCarrier : null; + + return this.net.request( + 'open-ils.circ', + 'open-ils.circ.holds.batch_update_holds_by_notify_staff', + this.auth.token(), this.patronId, holdIds, mod.oldValue, + mod.newValue, mod.field, carrierId + ); + + })) + .subscribe( + resp => console.log('GOT', resp), + err => console.error(err), + () => { + this.loading = false; + this.close(); + } + ); + } } -- 2.11.0