Afform GUI - Fix search display block saving
authorColeman Watts <coleman@civicrm.org>
Thu, 4 Feb 2021 15:07:06 +0000 (10:07 -0500)
committerColeman Watts <coleman@civicrm.org>
Thu, 4 Feb 2021 16:01:48 +0000 (11:01 -0500)
ext/afform/admin/ang/afGuiEditor/elements/afGuiContainer.component.js

index 745c596eeec217fb8d1fc49a970bdf0ad100671f..963a68eab23b065b922bab6dc8e980636427c430 100644 (file)
           model.block = afGui.meta.blocks[$scope.block.original].block;
         }
         else {
-          model.block = ctrl.getFieldEntityType('id') || '*';
+          model.block = ctrl.getFieldEntityType();
         }
         dialogService.open('saveBlockDialog', '~/afGuiEditor/saveBlock.html', model, options)
           .then(function(block) {
               }
             });
           }
-          if (!entityType && afGui.getField(searchDisplay['saved_search.api_entity'], fieldName)) {
+          if (!entityType && fieldName && afGui.getField(searchDisplay['saved_search.api_entity'], fieldName)) {
             entityType = searchDisplay['saved_search.api_entity'];
           }
           if (entityType) {
             return false;
           }
         });
-        return entityType;
+        return entityType || _.map(afGui.meta.searchDisplays, 'saved_search.api_entity')[0];
       };
 
     }