SearchKit - Fix JS undefined variable error when clearing field in update dialog
authorColeman Watts <coleman@civicrm.org>
Mon, 16 Aug 2021 19:41:50 +0000 (15:41 -0400)
committerColeman Watts <coleman@civicrm.org>
Mon, 16 Aug 2021 19:41:50 +0000 (15:41 -0400)
ext/search_kit/ang/crmSearchTasks/crmSearchInput/crmSearchInput.component.js
ext/search_kit/ang/crmSearchTasks/crmSearchInput/crmSearchInputVal.component.js

index c98d4705e5bf8270b3059c6ced3553bf0d260c29..b3bce0409d19162e7e7eaebd7de798da18386b24 100644 (file)
@@ -21,7 +21,7 @@
         }
         // If no search operator this is an input for e.g. the bulk update action
         // Return `true` if the field is multi-valued, else `null`
-        return ctrl.field.serialize || ctrl.field.data_type === 'Array' ? true : null;
+        return ctrl.field && (ctrl.field.serialize || ctrl.field.data_type === 'Array') ? true : null;
       };
 
       this.$onInit = function() {
index cd6dfe78cd7cd34c9d9c0a5afd49ed65b5769688..1e19729a71fd324c2b6bf2bdec5f7536e00ef76b 100644 (file)
       };
 
       this.getTemplate = function() {
+        var field = ctrl.field || {};
 
-        if (ctrl.field.input_type === 'Date') {
+        if (field.input_type === 'Date') {
           return '~/crmSearchTasks/crmSearchInput/date.html';
         }
 
-        if (ctrl.field.data_type === 'Boolean') {
+        if (field.data_type === 'Boolean') {
           return '~/crmSearchTasks/crmSearchInput/boolean.html';
         }
 
-        if (ctrl.field.options) {
+        if (field.options) {
           return '~/crmSearchTasks/crmSearchInput/select.html';
         }
 
-        if (ctrl.field.fk_entity || ctrl.field.name === 'id') {
+        if (field.fk_entity || field.name === 'id') {
           return '~/crmSearchTasks/crmSearchInput/entityRef.html';
         }
 
-        if (ctrl.field.data_type === 'Integer') {
+        if (field.data_type === 'Integer') {
           return '~/crmSearchTasks/crmSearchInput/integer.html';
         }
 
-        if (ctrl.field.data_type === 'Float') {
+        if (field.data_type === 'Float') {
           return '~/crmSearchTasks/crmSearchInput/float.html';
         }
 
       };
 
       this.getFieldOptions = function() {
-        return {results: formatForSelect2(ctrl.field.options, ctrl.optionKey || 'id', 'label', ['description', 'color', 'icon'])};
+        var field = ctrl.field || {};
+        return {results: formatForSelect2(field.options || [], ctrl.optionKey || 'id', 'label', ['description', 'color', 'icon'])};
       };
 
     }