Afform - Fix editing search filters nested within multiple containers
authorColeman Watts <coleman@civicrm.org>
Mon, 6 Mar 2023 21:13:20 +0000 (16:13 -0500)
committerColeman Watts <coleman@civicrm.org>
Mon, 6 Mar 2023 21:13:20 +0000 (16:13 -0500)
ext/afform/admin/ang/afGuiEditor/elements/afGuiContainer.component.js
ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js

index 06c8648d1a13a2a233c11989d1f04ad5295a8a28..79382e2ba4d71c8207943beae737f1e53c399849 100644 (file)
         }
       };
 
-      this.getSearchDisplay = function(node) {
-        var searchKey = $scope.getSearchKey(node);
-        if (searchKey) {
+      // Finds a SearchDisplay within this container or within the fieldset containing this container
+      this.getSearchDisplay = function() {
+        var searchKey = ctrl.getDataEntity();
+        if (searchKey && !ctrl.entityName) {
           return afGui.getSearchDisplay.apply(null, searchKey.split('.'));
         }
       };
           var joinType = ctrl.entityName.split('-join-');
           entityType = joinType[1] || (ctrl.editor && ctrl.editor.getEntity(joinType[0]).type);
         } else {
-          var searchKey = ctrl.getDataEntity(),
-            searchDisplay = afGui.getSearchDisplay.apply(null, searchKey.split('.')),
+          var searchDisplay = ctrl.getSearchDisplay(),
             fieldName = fieldKey.substr(fieldKey.indexOf('.') + 1),
             prefix = _.includes(fieldKey, '.') ? fieldKey.split('.')[0] : null;
           if (prefix) {
index 1550f94faaf0aa12deb8ba0128d58d18bdc5e031..66136f86f6574d446b0bff755fe57bea057f9db7 100644 (file)
@@ -89,8 +89,8 @@
       this.getDefn = function() {
         var defn = afGui.getField(ctrl.container.getFieldEntityType(ctrl.node.name), ctrl.node.name);
         // Calc fields are specific to a search display, not part of the schema
-        if (!defn && ctrl.container.getSearchDisplay(ctrl.container.node)) {
-          var searchDisplay = ctrl.container.getSearchDisplay(ctrl.container.node);
+        if (!defn && ctrl.container.getSearchDisplay()) {
+          var searchDisplay = ctrl.container.getSearchDisplay();
           defn = _.findWhere(searchDisplay.calc_fields, {name: ctrl.node.name});
         }
         defn = defn || {