LP1889128 Support user settings for SMS prefs
authorBill Erickson <berickxx@gmail.com>
Mon, 19 Oct 2020 15:03:43 +0000 (11:03 -0400)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 6 Jan 2021 00:48:27 +0000 (16:48 -0800)
Honor the user setting values 'opac.default_sms_carrier' and
'opac.default_sms_notify' in the Angular staff catalog place holds form.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>

Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts

index 3c47fbb..6a1147d 100644 (file)
               <label i18n>SMS Carrier</label>
             </div>
             <div class="flex-1">
-              <eg-combobox [disabled]="!notifySms"
+              <eg-combobox [disabled]="!notifySms" #smsCbox
                 placeholder="SMS Carriers" i18n-placeholder
                 [entries]="smsCarriers">
               </eg-combobox>
index 2350890..59f6a54 100644 (file)
@@ -14,7 +14,7 @@ import {CatalogService} from '@eg/share/catalog/catalog.service';
 import {StaffCatalogService} from '../catalog.service';
 import {HoldsService, HoldRequest,
     HoldRequestTarget} from '@eg/staff/share/holds/holds.service';
-import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
+import {ComboboxEntry, ComboboxComponent} from '@eg/share/combobox/combobox.component';
 import {PatronService} from '@eg/staff/share/patron/patron.service';
 import {PatronSearchDialogComponent
   } from '@eg/staff/share/patron/search-dialog.component';
@@ -62,7 +62,6 @@ export class HoldComponent implements OnInit {
     phoneValue: string;
     notifySms: boolean;
     smsValue: string;
-    smsCarrier: string;
     suspend: boolean;
     activeDate: string;
 
@@ -89,6 +88,8 @@ export class HoldComponent implements OnInit {
     @ViewChild('patronSearch', {static: false})
       patronSearch: PatronSearchDialogComponent;
 
+    @ViewChild('smsCbox', {static: false}) smsCbox: ComboboxComponent;
+
     constructor(
         private router: Router,
         private route: ActivatedRoute,
@@ -358,10 +359,13 @@ export class HoldComponent implements OnInit {
         this.user = null;
         this.notifyEmail = true;
         this.notifyPhone = true;
+        this.notifySms = false;
         this.phoneValue = '';
         this.pickupLib = this.requestor.ws_ou();
         this.currentUserBarcode = null;
         this.multiHoldCount = 1;
+        this.smsValue = '';
+        if (this.smsCbox) { this.smsCbox.selectedId = null; }
 
         // Avoid clearing the barcode in cases where the form is
         // reset as the result of a barcode change.
@@ -419,6 +423,22 @@ export class HoldComponent implements OnInit {
                 case 'opac.default_phone':
                     this.phoneValue = value;
                     break;
+
+                case 'opac.default_sms_carrier':
+                    setTimeout(() => {
+                        // timeout creates an extra window where the cbox
+                        // can be rendered in cases where the hold receipient
+                        // is known at page load time.  This out of an
+                        // abundance of caution.
+                        if (this.smsCbox) {
+                            this.smsCbox.selectedId = Number(value);
+                        }
+                    });
+                    break;
+
+                case 'opac.default_sms_notify':
+                    this.smsValue = value;
+                    break;
             }
         });
 
@@ -512,7 +532,7 @@ export class HoldComponent implements OnInit {
             notifyEmail: this.notifyEmail, // bool
             notifyPhone: this.notifyPhone ? this.phoneValue : null,
             notifySms: this.notifySms ? this.smsValue : null,
-            smsCarrier: this.notifySms ? this.smsCarrier : null,
+            smsCarrier: this.smsCbox ? this.smsCbox.selectedId : null,
             thawDate: this.suspend ? this.activeDate : null,
             frozen: this.suspend,
             holdableFormats: selectedFormats