SearchKit - Consistently check for date field
authorColeman Watts <coleman@civicrm.org>
Wed, 4 May 2022 00:49:56 +0000 (20:49 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 4 May 2022 00:49:56 +0000 (20:49 -0400)
ext/search_kit/ang/crmSearchTasks/crmSearchInput/crmSearchInputVal.component.js

index 6d54653605c4463541643156cf86da80f0441d12..a249019898ceb36389faacd84d3135988edce4ab 100644 (file)
@@ -21,7 +21,7 @@
 
         this.ngModel.$render = function() {
           ctrl.value = ctrl.ngModel.$viewValue;
-          if (!rendered && field.input_type === 'Date') {
+          if (!rendered && isDateField(field)) {
             setDateType();
           }
           rendered = true;
           return '~/crmSearchTasks/crmSearchInput/text.html';
         }
 
-        if (field.data_type === 'Date' || field.data_type === 'Timestamp') {
+        if (isDateField(field)) {
           return '~/crmSearchTasks/crmSearchInput/date.html';
         }
 
         return {results: formatForSelect2(field.options || [], ctrl.optionKey || 'id', 'label', ['description', 'color', 'icon'])};
       };
 
+      function isDateField(field) {
+        return field.data_type === 'Date' || field.data_type === 'Timestamp';
+      }
+
     }
   });