LP#1933381 Notify by SMS requires SMS fields when placing holds
authorDan Briem <dbriem@wlsmail.org>
Sat, 31 Jul 2021 02:34:26 +0000 (22:34 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 12 Aug 2021 21:49:13 +0000 (17:49 -0400)
When placing a hold, if the notification method is set to SMS
and no carrier is selected, the hold fails with a generic error.

This disables the Place Hold(s) button if notify by SMS is
selected and the SMS phone number or carrier fields are not set.

Signed-off-by: Dan Briem <dbriem@wlsmail.org>
Signed-off-by: Erica Rohlfs <erica.rohlfs@equinoxOLI.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
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 0e764ff..cdc864d 100644 (file)
                   <label for="smsValue" class="input-group-text" i18n>SMS Number</label>
                 </div>
                 <input type="text" class="form-control" [disabled]="!notifySms"
-                  id="smsValue" name="smsValue" [(ngModel)]="smsValue"/>
+                  id="smsValue" name="smsValue" [(ngModel)]="smsValue"
+                  [required]="notifySms"/>
               </div>
             </div>
           </li>
             </div>
             <div class="flex-1">
               <eg-combobox [disabled]="!notifySms" #smsCbox
-                domId="smsCarriers"
+                domId="smsCarriers" [required]="notifySms"
                 placeholder="SMS Carriers" i18n-placeholder
                 [entries]="smsCarriers">
               </eg-combobox>
           </li>
           <li class="list-group-item">
             <button class="btn btn-success" (click)="placeHolds()"
-              [disabled]="!user || placeHoldsClicked" i18n>Place Hold(s)</button>
+              [disabled]="!readyToPlaceHolds()" i18n>Place Hold(s)</button>
 
             <button class="btn btn-outline-dark ml-2" (click)="resetForm()" i18n>Reset</button>
           </li>
index ef10228..5399cd3 100644 (file)
@@ -475,6 +475,18 @@ export class HoldComponent implements OnInit {
         }
     }
 
+    readyToPlaceHolds(): boolean {
+        if (!this.user || this.placeHoldsClicked) {
+            return false;
+        }
+        if (this.notifySms) {
+            if (!this.smsValue.length || !this.smsCbox?.selectedId) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     // Attempt hold placement on all targets
     placeHolds(idx?: number) {
         if (!idx) {