SearchKit - Fix wrong flags shown when switching field functions
authorcolemanw <coleman@civicrm.org>
Fri, 17 Nov 2023 14:04:37 +0000 (09:04 -0500)
committercolemanw <coleman@civicrm.org>
Fri, 17 Nov 2023 14:34:01 +0000 (09:34 -0500)
ext/search_kit/ang/crmSearchAdmin/crmSearchFunctionFlag.component.js
ext/search_kit/ang/crmSearchAdmin/crmSearchFunctionFlag.html

index ee6948ada5847519c29297e1986340b6d02f38ed..24db599dd31e4c092add257d6cfc0b42cf1610d9 100644 (file)
       var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'),
         ctrl = this;
 
-      this.$onInit = function() {
+      this.getWidget = function() {
         if (!ctrl.param || !ctrl.param[ctrl.flag]) {
-          this.widget = null;
+          return null;
         } else if (_.keys(ctrl.param[ctrl.flag]).length === 2 && '' in ctrl.param[ctrl.flag]) {
-          this.widget = 'checkbox';
+          return 'checkbox';
         } else {
-          this.widget = 'select';
+          return 'select';
         }
       };
     }
index f2227e5eeda8c305c74d4b0b9ad19ff42b5333f4..32a126b0fda5f8c9f89bf62520872413a3de17ff 100644 (file)
@@ -1,4 +1,4 @@
-<span ng-switch="$ctrl.widget">
+<span ng-switch="$ctrl.getWidget()">
   <span ng-switch-when="checkbox">
     <label ng-repeat="(val, label) in $ctrl.param[$ctrl.flag]" ng-if="val">
       <input type="checkbox" ng-checked="$ctrl.arg[$ctrl.flag] === val" ng-click="$ctrl.arg[$ctrl.flag] = ($ctrl.arg[$ctrl.flag] === val ? null : val); $ctrl.writeExpr();" >