improvements to timestamp queries
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 8 Jul 2020 20:26:37 +0000 (16:26 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 8 Jul 2020 20:26:37 +0000 (16:26 -0400)
- now work correctly as saved searches or URL parameters
- when changing between search fields that are both
  timestamps, the value is now retained.

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 89a8438..2443325 100644 (file)
           </ng-container>
         </ng-container>
         <eg-date-select *ngIf="searchTermDatatypes[t.field] == 'timestamp' && t.op != '__age'"
+          [initialIso]="t.value1"
           (onChangeAsIso)="t.value1 = $event ? $event : ''; t.is_date = true">
         </eg-date-select>
         <ng-container *ngIf="searchTermDatatypes[t.field] == 'timestamp' && t.op == '__between'">
           <span i18n>and</span>
           <eg-date-select
+            [initialIso]="t.value2"
             (onChangeAsIso)="t.value2 = $event ? $event : ''; t.is_date = true">
           </eg-date-select>
         </ng-container>
index d9355aa..f17309f 100644 (file)
@@ -142,24 +142,25 @@ export class AcqSearchFormComponent implements OnInit, AfterViewInit, OnChanges
             if (this.searchTerms[0].field && this.searchTermDatatypes[this.searchTerms[0].field] == 'org_unit') {
                 this.searchTerms = [{ field: this.searchTerms[0].field, op: this.searchTerms[0].op, value1: '', value2: ''}];
             }
+            // and timestamps
+            if (this.searchTerms[0].field && this.searchTermDatatypes[this.searchTerms[0].field] == 'timestamp') {
+                this.searchTerms = [{ field: this.searchTerms[0].field, op: this.searchTerms[0].op, value1: '', value2: ''}];
+            }
         } else {
             this.searchTerms.splice(index, 1);
         }
     }
     clearSearchTerm(term: AcqSearchTerm, old?) {
-        if (!old) {
-            term.value1 = '';
-            term.value2 = '';
-        }
-        term.is_date = false;
-
         // work around fact that org selector doesn't implement ngModel
-        if (old && this.searchTermDatatypes[old] == this.searchTermDatatypes[term.field] && this.searchTermDatatypes[old] == 'org_unit') {
+        // and we don't use it for eg-date-select
+        if (old && this.searchTermDatatypes[old] == this.searchTermDatatypes[term.field] &&
+            (this.searchTermDatatypes[old] == 'org_unit' || this.searchTermDatatypes[old] == 'timestamp')) {
             // don't change values if we're moving from one
-            // org_unit field to another
+            // org_unit or timestamp field to another
         } else {
             term.value1 = '';
             term.value2 = '';
+            term.is_date = false;
         }
 
         // handle change of field type