LP1819236 Ang cat prevent keyword starts/exact searches
authorBill Erickson <berickxx@gmail.com>
Thu, 19 Sep 2019 20:14:06 +0000 (16:14 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 21 Feb 2020 16:44:38 +0000 (11:44 -0500)
Prevent users from attempting Keyword starts-with or matches-exactly
searches since these are nonsensical.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Ruth Frasur <rfrasur@gmail.com>
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts

index f5d2e50..920b008 100644 (file)
@@ -35,6 +35,7 @@
             </div>
             <div class="col-lg-2 pl-0 pr-2">
               <select class="form-control" 
+                (change)="preventBogusCombos(idx)"
                 [(ngModel)]="context.termSearch.fieldClass[idx]">
                 <option i18n value='keyword'>Keyword</option>
                 <option i18n value='title'>Title</option>
                 <option i18n value='contains'>Contains</option>
                 <option i18n value='nocontains'>Does not contain</option>
                 <option i18n value='phrase'>Contains phrase</option>
-                <option i18n value='exact'>Matches exactly</option>
-                <option i18n value='starts'>Starts with</option>
+                <option [disabled]="context.termSearch.fieldClass[idx]=='keyword'"
+                  i18n value='exact'>Matches exactly</option>
+                <option [disabled]="context.termSearch.fieldClass[idx]=='keyword'"
+                  i18n value='starts'>Starts with</option>
               </select>
             </div>
             <div class="col-lg-4 pl-0 pr-2">
index 357f7be..043adb0 100644 (file)
@@ -269,6 +269,16 @@ export class SearchFormComponent implements OnInit, AfterViewInit {
     searchIsActive(): boolean {
         return this.context.searchState === CatalogSearchState.SEARCHING;
     }
+
+    // It's possible to chose invalid combos depending on the order of selection
+    preventBogusCombos(idx: number) {
+        if (this.context.termSearch.fieldClass[idx] === 'keyword') {
+            const op = this.context.termSearch.matchOp[idx];
+            if (op === 'exact' || op === 'starts') {
+                this.context.termSearch.matchOp[idx] = 'contains';
+            }
+        }
+    }
 }