Afform - fix contact source field
authorColeman Watts <coleman@civicrm.org>
Mon, 23 Aug 2021 18:43:18 +0000 (14:43 -0400)
committerColeman Watts <coleman@civicrm.org>
Mon, 23 Aug 2021 18:43:18 +0000 (14:43 -0400)
Contact source is supposed to take its default from the afform title
This fixes it to initialize with the title and keep in sync.

ext/afform/admin/ang/afGuiEditor/afGuiEditor.component.js

index 13a4bbe5ad3194ba10376d8c35b101b9b29d77f7..275b2827e6d095c68dba906e62a92d0076fef6d3 100644 (file)
         while (!!$scope.entities[type + num]) {
           num++;
         }
-        $scope.entities[type + num] = backfillEntityDefaults(_.assign($parse(meta.defaults)($scope), {
+        $scope.entities[type + num] = backfillEntityDefaults(_.assign($parse(meta.defaults)(editor), {
           '#tag': 'af-entity',
           type: meta.entity,
           name: type + num,
       $scope.$watch('editor.afform.title', function(newTitle, oldTitle) {
         if (typeof oldTitle === 'string') {
           _.each($scope.entities, function(entity) {
-            if (entity.data && entity.data.source === oldTitle) {
+            if (entity.data && 'source' in entity.data && (entity.data.source || '') === oldTitle) {
               entity.data.source = newTitle;
             }
           });