From 79868cc2a719aca1fea526b9e02a8bd492963e8f Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 2 Oct 2020 20:45:47 -0400 Subject: [PATCH] Updates for Angular 1.8 - fix premature access to component properties 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 | 4 ++-- ext/search/ang/search/crmSearchFunction.component.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/search/ang/search/crmSearchActions.component.js b/ext/search/ang/search/crmSearchActions.component.js index 6711ea135b..73ed61a092 100644 --- a/ext/search/ang/search/crmSearchActions.component.js +++ b/ext/search/ang/search/crmSearchActions.component.js @@ -12,10 +12,10 @@ 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)) { diff --git a/ext/search/ang/search/crmSearchFunction.component.js b/ext/search/ang/search/crmSearchFunction.component.js index 9b7efce4b8..1b2c45832d 100644 --- a/ext/search/ang/search/crmSearchFunction.component.js +++ b/ext/search/ang/search/crmSearchFunction.component.js @@ -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; -- 2.25.1