Updates for Angular 1.8 - fix premature access to component properties
authorColeman Watts <coleman@civicrm.org>
Sat, 3 Oct 2020 00:45:47 +0000 (20:45 -0400)
committerColeman Watts <coleman@civicrm.org>
Sun, 4 Oct 2020 02:05:22 +0000 (22:05 -0400)
Angular 1.8 doesn't seem to like it when you try to access component properties
before the init function.

ext/search/ang/search/crmSearchActions.component.js
ext/search/ang/search/crmSearchFunction.component.js

index 6711ea135ba7cb5494b54f62ab49820ba9677d1d..73ed61a0923dbb7281f453c5dfcc182533658dfd 100644 (file)
     templateUrl: '~/search/crmSearchActions.html',
     controller: function($scope, crmApi4, dialogService, searchMeta) {
       var ts = $scope.ts = CRM.ts(),
-        entityTitle = searchMeta.getEntity(this.entity).titlePlural,
         ctrl = this;
 
-      this.init = function() {
+      this.$onInit = function() {
+        var entityTitle = searchMeta.getEntity(ctrl.entity).titlePlural;
         if (!ctrl.actions) {
           var actions = _.transform(_.cloneDeep(CRM.vars.search.actions), function (actions, action) {
             if (_.includes(action.entities, ctrl.entity)) {
index 9b7efce4b8379b33defb1fc61a8a5ce81001dfee..1b2c45832d85c5b2ee7f56b0ff1510f46feb0281 100644 (file)
@@ -10,9 +10,9 @@
     controller: function($scope, formatForSelect2, searchMeta) {
       var ts = $scope.ts = CRM.ts(),
         ctrl = this;
-      this.functions = formatForSelect2(_.where(CRM.vars.search.functions, {category: this.cat}), 'name', 'title');
 
       this.$onInit = function() {
+        ctrl.functions = formatForSelect2(_.where(CRM.vars.search.functions, {category: ctrl.cat}), 'name', 'title');
         var fieldInfo = searchMeta.parseExpr(ctrl.expr);
         ctrl.path = fieldInfo.path + fieldInfo.suffix;
         ctrl.field = fieldInfo.field;