LP1904036 Hold notify mods
authorBill Erickson <berickxx@gmail.com>
Thu, 1 Apr 2021 19:17:14 +0000 (15:17 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:29 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/hold-notify-update.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/hold-notify-update.component.ts

index d8951c8..39ec61a 100644 (file)
 </ng-template>
 
 
-<ng-template #userSettingsInputRow let-args="args">
+<ng-template #userSettingInputRow let-args="args">
   <div class="row pt-1 pb-1 mt-1">
     <ng-container *ngTemplateOutlet="userSettingLabel; context: {args: args}">
     </ng-container>
     <div class="m-auto font-weight-bold" i18n>User Settings</div>
   </div>
 
-  <ng-container *ngTemplateOutlet="userSettingsInputRow; context: 
+  <ng-container *ngTemplateOutlet="userSettingInputRow; context: 
     {args: {settingName: 'opac.default_phone'}}">
   </ng-container>
 
       <ng-container *ngTemplateOutlet="userSettingLabel; 
         context: {args: {settingName: 'opac.default_sms_notify'}}">
       </ng-container>
-      <ng-container *ngTemplateOutlet="userSettingsInput;
+      <ng-container *ngTemplateOutlet="userSettingInput;
         context: {args: {settingName: 'opac.default_sms_notify'}}">
       </ng-container>
       <div class="col-lg-6">
index 45ee036..03c1b7a 100644 (file)
@@ -30,7 +30,7 @@ const COMMON_USER_SETTING_TYPES = [
   'opac.hold_notify',
   'opac.default_phone',
   'opac.default_pickup_location',
-  'opac.default_sms_carrier_id',
+  'opac.default_sms_carrier',
   'opac.default_sms_notify'
 ];
 
@@ -170,7 +170,7 @@ export class EditComponent implements OnInit, AfterViewInit {
         evening_phone: null,
         default_phone: null,
         default_sms: null,
-        default_sms_carrier_id: null,
+        default_sms_carrier: null,
         phone_notify: false,
         email_notify: false,
         sms_notify: false
@@ -538,9 +538,9 @@ export class EditComponent implements OnInit, AfterViewInit {
                 = holdNotify.match(/sms/) !== null;
         }
 
-        if (setting = usets['opac.default_sms_carrier_id']) {
-            setting = usets['opac.default_sms_carrier_id'] = Number(setting);
-            this.holdNotifyValues.default_sms_carrier_id = setting;
+        if (setting = usets['opac.default_sms_carrier']) {
+            setting = usets['opac.default_sms_carrier'] = Number(setting);
+            this.holdNotifyValues.default_sms_carrier = setting;
         }
 
         if (setting = usets['opac.default_phone']) {
@@ -1242,6 +1242,17 @@ export class EditComponent implements OnInit, AfterViewInit {
 
         let settings: any = {};
 
+        const holdMethods = [];
+
+        ['email', 'phone', 'sms'].forEach(method => {
+            if (this.holdNotifyTypes[method]) {
+                holdMethods.push(method);
+            }
+        });
+
+        this.userSettings['opac.hold_notify'] =
+            holdMethods.length > 0 ?  holdMethods.join(':') : null;
+
         if (this.patronId) {
             // Update all user editor setting values for existing
             // users regardless of whether a value changed.
@@ -1271,11 +1282,26 @@ export class EditComponent implements OnInit, AfterViewInit {
 
         return this.collectHoldNotifyChange()
         .then(mods => {
+
             if (mods.length === 0) { return Promise.resolve(); }
 
+            console.log('HOLD NOTIFY MODS', mods);
+
             this.holdNotifyUpdateDialog.smsCarriers = this.smsCarriers;
             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.defaultCarrier =
+                this.userSettings['opac.default_sms_carrier']
+                || this.holdNotifyValues.default_sms_carrier;
+
             return this.holdNotifyUpdateDialog.open().toPromise();
         });
     }
@@ -1307,10 +1333,15 @@ export class EditComponent implements OnInit, AfterViewInit {
             // No change to apply?
             if (newValue === oldValue) { return empty(); }
 
+            // API / user setting name mismatch
+            if (field.match(/carrier/)) { field += '_id'; }
+
+            const apiValue = field.match(/notify|carrier/) ? oldValue : newValue;
+
             return this.net.request(
                 'open-ils.circ',
                 'open-ils.circ.holds.retrieve_by_notify_staff',
-                this.auth.token(), this.patronId, newValue, field
+                this.auth.token(), this.patronId, apiValue, field
             ).pipe(tap(holds => {
                 if (holds && holds.length > 0) {
                     mods.push({
index 3c8236e..45d7684 100644 (file)
     <div class="row mt-2" *ngFor="let mod of mods">
       <div class="col-lg-12">
 
-        <!-- TODO pref change wording -->
+        <div [ngSwitch]="mod.field" class="mt-2 mb-2">
+          <span *ngSwitchCase="'phone_notify'">You have set Notify by Phone to</span>
+          <span *ngSwitchCase="'sms_notify'">You have set Notify by SMS to</span>
+          <span *ngSwitchCase="'email_notify'">You have set Notify by Email to</span>
+          <span *ngSwitchCase="'default_phone'">You have set Default Phone Number to</span>
+          <span *ngSwitchCase="'default_sms'">You have set Default SMS/Text Number to</span>
+          <eg-bool [value]="mod.newValue"></eg-bool>
+        </div>
+
+        <div class="mt-2 mb-2" *ngIf="mod.name == 'default_sms_carrier_id'">
+          You have set Default SMS Carrier to {{carrierName(mod.newValue)}}
+        </div>
 
         <div class="form-check form-check-inline">
           <input class="form-check-input" type="checkbox" 
             id="{{mod.field}}-checkbox" [(ngModel)]="selected[mod.field]"/>
           <label class="form-check-label" for="{{mod.field}}-checkbox">
             <ng-container *ngIf="isCarrierChange(mod)" i18n>
-              A carrier other than "{{carrierName(mod.oldValue)}}" 
-              is currently used in {{mod.holds.length}} hold(s). 
-              Update to "{{carrierName(mod.newValue)}}"?
+              A carrier other than "{{carrierName(mod.oldValue)}}" is
+              currently used in {{mod.holds.length}} hold(s).  Update to
+              "{{carrierName(mod.newValue)}}"?
             </ng-container>
             <ng-container *ngIf="isBoolChange(mod)" i18n>
               {{mod.holds.length}} hold(s) have it set to 
index 41e73e4..742d76a 100644 (file)
@@ -33,6 +33,9 @@ export class HoldNotifyUpdateDialogComponent
     // Values provided directly by our parent component
     smsCarriers: ComboboxEntry[];
     mods: HoldNotifyMod[] = [];
+    defaultSms: string;
+    defaultPhone: string;
+    defaultCarrier: number;
 
     selected: {[field: string]: boolean} = {};