clear search value upon changing selected field
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 17 Jan 2020 16:43:00 +0000 (11:43 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 17 Jan 2020 16:47:14 +0000 (11:47 -0500)
TODO: consider if there are cases where we're OK not
      clearing the field, e.g., if both the previous
      and new fields both have the same type. Note
      that just clearing the value is what the Dojo
      interface did.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.html
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts

index a9db419..0eb91f9 100644 (file)
@@ -6,7 +6,8 @@
 </div>
 <div class="row" *ngFor="let t of searchTerms">
   <div class="col-lg-3">
-    <select class="form-control" id="selected-search-term" [ngModelOptions]="{standalone: true}" [(ngModel)]="t.field">
+    <select class="form-control" id="selected-search-term" [ngModelOptions]="{standalone: true}" [(ngModel)]="t.field"
+      (change)="clearSearchTerm(t)">
       <option disabled="disabled" i18n>Select Search Field</option>
       <optgroup *ngFor="let g of hints" label="{{availableSearchFields[g]['__label']}}">
         <option *ngFor="let o of availableSearchFields[g]['__fields']" value="{{g}}:{{o}}">
index 33b9ed5..2c40c5a 100644 (file)
@@ -108,6 +108,11 @@ export class AcqSearchComponent implements OnInit, AfterViewInit {
     addSearchTerm() {
         this.searchTerms.push({ field: '', op: '', value1: '', value2: '' });
     }
+    clearSearchTerm(term: AcqSearchTerm) {
+        term.value1 = '';
+        term.value2 = '';
+        term.is_date = false;
+    }
 
     setOrgUnitSearchValue(org: IdlObject, term: AcqSearchTerm) {
         if (org == null) {
index d367de7..3f0d546 100644 (file)
@@ -101,7 +101,9 @@ export class AcqSearchService {
 
         // handle supplied search terms
         this._terms.forEach(term => {
-            if (term.value1 === '') return;
+            if (term.value1 === '') {
+                return;
+            }
             const searchTerm: Object = {};
             const recType = term.field.split(':')[0];
             const searchField = term.field.split(':')[1];