hook up __age, __starts, and __ends operators
authorGalen Charlton <gmc@equinoxinitiative.org>
Sun, 19 Jan 2020 20:20:48 +0000 (15:20 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Sun, 19 Jan 2020 20:20:48 +0000 (15:20 -0500)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.html
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.ts

index 3138a5f..2d686b5 100644 (file)
     </select>
   </div>
   <div class="col-lg-2">
-    <select class="form-control" id="selected-search-op" [ngModelOptions]="{standalone: true}" [(ngModel)]="t.op">
+    <select class="form-control" id="selected-search-op" [ngModelOptions]="{standalone: true}" [(ngModel)]="t.op"
+      (change)="clearSearchTermValueAfterOpChange(t)">
       <option i18n value="">is</option>
       <option i18n value="__not">is NOT</option>
       <option i18n value="__fuzzy" [disabled]="searchTermDatatypes[t.field] != 'text'">contains</option>
       <option i18n value="__not,__fuzzy" [disabled]="searchTermDatatypes[t.field] != 'text'">does NOT contain</option>
+      <option i18n value="__starts" [disabled]="searchTermDatatypes[t.field] != 'text'">STARTS with</option>
+      <option i18n value="__ends" [disabled]="searchTermDatatypes[t.field] != 'text'">ENDS with</option>
       <option i18n value="__lte" [disabled]="searchTermDatatypes[t.field] != 'timestamp'">is on or BEFORE</option>
       <option i18n value="__gte" [disabled]="searchTermDatatypes[t.field] != 'timestamp'">is on or AFTER</option>
+      <option i18n value="__age" [disabled]="searchTermDatatypes[t.field] != 'timestamp'">age (relative date)</option>
       <option i18n value="__in">matches a term from a file</option>
     </select>
   </div>
         [idlClass]="searchFieldLinkedClasses[t.field]"
         (onChange)="t.value1 = $event ? $event.id : ''">
       </eg-combobox>
-      <eg-date-select *ngIf="searchTermDatatypes[t.field] == 'timestamp'"
+      <eg-date-select *ngIf="searchTermDatatypes[t.field] == 'timestamp' && t.op != '__age'"
         (onChangeAsIso)="t.value1 = $event ? $event : ''; t.is_date = true">
       </eg-date-select>
+      <input [(ngModel)]="t.value1" type="text" *ngIf="searchTermDatatypes[t.field] == 'timestamp' && t.op == '__age'" class="form-control" />
     </ng-container>
   </div>
   <div class="col-lg-2 pl-0 pr-1">
index f1e9623..9b92117 100644 (file)
@@ -91,6 +91,14 @@ export class AcqSearchFormComponent implements OnInit, AfterViewInit {
         term.value2 = '';
         term.is_date = false;
     }
+    // conditionally clear the search term after changing
+    // to selected search operators
+    clearSearchTermValueAfterOpChange(term: AcqSearchTerm) {
+        if (term.op === '__age') {
+            term.value1 = '';
+            term.value2 = '';
+        }
+    }
 
     setOrgUnitSearchValue(org: IdlObject, term: AcqSearchTerm) {
         if (org == null) {