Afform GUI - Rename service from afAdmin to afGiu
authorColeman Watts <coleman@civicrm.org>
Mon, 11 Jan 2021 19:35:25 +0000 (14:35 -0500)
committerColeman Watts <coleman@civicrm.org>
Tue, 19 Jan 2021 17:20:20 +0000 (12:20 -0500)
ext/afform/admin/ang/afGuiEditor.js
ext/afform/admin/ang/afGuiEditor/afGuiEditor.component.js
ext/afform/admin/ang/afGuiEditor/afGuiEntity.component.js
ext/afform/admin/ang/afGuiEditor/afGuiMenuItemBackground.component.js
ext/afform/admin/ang/afGuiEditor/afGuiMenuItemBorder.component.js
ext/afform/admin/ang/afGuiEditor/elements/afGuiButton.component.js
ext/afform/admin/ang/afGuiEditor/elements/afGuiContainer.component.js
ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js
ext/afform/admin/ang/afGuiEditor/elements/afGuiText.component.js

index d604e57fb36851231bd83c3ddb8015fc6b52b0a6..2acf4f7322a8a136968270e4dc8202235ac4db39 100644 (file)
@@ -2,7 +2,7 @@
   "use strict";
   angular.module('afGuiEditor', CRM.angRequires('afGuiEditor'))
 
-    .service('afAdmin', function(crmApi4, $parse, $q) {
+    .service('afGui', function(crmApi4, $parse, $q) {
 
       // Parse strings of javascript that php couldn't interpret
       function evaluate(collection) {
index 7cdc06b35e89a043fcf84b727ab5bb97c11b4204..428b903684f23f6945391d2ebbce8bbf9acabce5 100644 (file)
@@ -8,12 +8,12 @@
       name: '<'
     },
     controllerAs: 'editor',
-    controller: function($scope, crmApi4, afAdmin, $parse, $timeout, $location) {
+    controller: function($scope, crmApi4, afGui, $parse, $timeout, $location) {
       var ts = $scope.ts = CRM.ts('afform');
       $scope.afform = null;
       $scope.saving = false;
       $scope.selectedEntityName = null;
-      this.meta = afAdmin.meta;
+      this.meta = afGui.meta;
       var editor = this;
       var newForm = {
         title: '',
@@ -27,7 +27,7 @@
 
       this.$onInit = function() {
         // Fetch the current form plus all blocks
-        afAdmin.initialize(editor.name)
+        afGui.initialize(editor.name)
           .then(initializeForm);
       };
 
         }
         $scope.canvasTab = 'layout';
         $scope.layoutHtml = '';
-        editor.layout = afAdmin.findRecursive($scope.afform.layout, {'#tag': 'af-form'})[0];
-        $scope.entities = afAdmin.findRecursive(editor.layout['#children'], {'#tag': 'af-entity'}, 'name');
+        editor.layout = afGui.findRecursive($scope.afform.layout, {'#tag': 'af-form'})[0];
+        $scope.entities = afGui.findRecursive(editor.layout['#children'], {'#tag': 'af-entity'}, 'name');
 
         if (editor.name == '0') {
           editor.addEntity('Individual');
-          editor.layout['#children'].push(afAdmin.meta.elements.submit.element);
+          editor.layout['#children'].push(afGui.meta.elements.submit.element);
         }
 
         // Set changesSaved to true on initial load, false thereafter whenever changes are made to the model
@@ -69,7 +69,7 @@
       };
 
       this.addEntity = function(type) {
-        var meta = afAdmin.meta.entities[type],
+        var meta = afGui.meta.entities[type],
           num = 1;
         // Give this new entity a unique name
         while (!!$scope.entities[type + num]) {
@@ -85,7 +85,7 @@
         var pos = 1 + _.findLastIndex(editor.layout['#children'], {'#tag': 'af-entity'});
         editor.layout['#children'].splice(pos, 0, $scope.entities[type + num]);
         // Create a new af-fieldset container for the entity
-        var fieldset = _.cloneDeep(afAdmin.meta.elements.fieldset.element);
+        var fieldset = _.cloneDeep(afGui.meta.elements.fieldset.element);
         fieldset['af-fieldset'] = type + num;
         fieldset['#children'][0]['#children'][0]['#text'] = meta.label + ' ' + num;
         // Add default contact name block
 
       this.removeEntity = function(entityName) {
         delete $scope.entities[entityName];
-        afAdmin.removeRecursive(editor.layout['#children'], {'#tag': 'af-entity', name: entityName});
-        afAdmin.removeRecursive(editor.layout['#children'], {'af-fieldset': entityName});
+        afGui.removeRecursive(editor.layout['#children'], {'#tag': 'af-entity', name: entityName});
+        afGui.removeRecursive(editor.layout['#children'], {'af-fieldset': entityName});
         this.selectEntity(null);
       };
 
index 37a141614d219d266fe96c15152abaf63a7b9d89..4c5c8d8a470c79cacb395d8507d42a4e8dd9cf47 100644 (file)
@@ -8,7 +8,7 @@
       entity: '<'
     },
     require: {editor: '^^afGuiEditor'},
-    controller: function ($scope, $timeout, afAdmin) {
+    controller: function ($scope, $timeout, afGui) {
       var ts = $scope.ts = CRM.ts();
       var ctrl = this;
       $scope.controls = {};
       }
 
       $scope.getMeta = function() {
-        return afAdmin.meta.entities[getEntityType()];
+        return afGui.meta.entities[getEntityType()];
       };
 
-      $scope.getField = afAdmin.getField;
+      $scope.getField = afGui.getField;
 
       $scope.valuesFields = function() {
         var fields = _.transform($scope.getMeta().fields, function(fields, field) {
@@ -55,7 +55,7 @@
           fields: filterFields($scope.getMeta().fields)
         });
 
-        _.each(afAdmin.meta.entities, function(entity, entityName) {
+        _.each(afGui.meta.entities, function(entity, entityName) {
           if (check(ctrl.editor.layout['#children'], {'af-join': entityName})) {
             $scope.fieldList.push({
               entityName: ctrl.entity.name + '-join-' + entityName,
@@ -81,7 +81,7 @@
       function buildBlockList(search) {
         $scope.blockList.length = 0;
         $scope.blockTitles.length = 0;
-        _.each(afAdmin.meta.blocks, function(block, directive) {
+        _.each(afGui.meta.blocks, function(block, directive) {
           if ((!search || _.contains(directive, search) || _.contains(block.name.toLowerCase(), search) || _.contains(block.title.toLowerCase(), search)) &&
             (block.block === '*' || block.block === ctrl.entity.type || (ctrl.entity.type === 'Contact' && block.block === ctrl.entity.data.contact_type))
           ) {
       function buildElementList(search) {
         $scope.elementList.length = 0;
         $scope.elementTitles.length = 0;
-        _.each(afAdmin.meta.elements, function(element, name) {
+        _.each(afGui.meta.elements, function(element, name) {
           if (!search || _.contains(name, search) || _.contains(element.title.toLowerCase(), search)) {
             var node = _.cloneDeep(element.element);
             if (name === 'fieldset') {
         if (block['af-join']) {
           return check(ctrl.editor.layout['#children'], {'af-join': block['af-join']});
         }
-        var fieldsInBlock = _.pluck(afAdmin.findRecursive(afAdmin.meta.blocks[block['#tag']].layout, {'#tag': 'af-field'}), 'name');
+        var fieldsInBlock = _.pluck(afGui.findRecursive(afGui.meta.blocks[block['#tag']].layout, {'#tag': 'af-field'}), 'name');
         return check(ctrl.editor.layout['#children'], function(item) {
           return item['#tag'] === 'af-field' && _.includes(fieldsInBlock, item.name);
         });
               check(item['#children'], criteria, found);
             }
             // Recurse into block directives
-            else if (item['#tag'] && item['#tag'] in afAdmin.meta.blocks) {
-              check(afAdmin.meta.blocks[item['#tag']].layout, criteria, found);
+            else if (item['#tag'] && item['#tag'] in afGui.meta.blocks) {
+              check(afGui.meta.blocks[item['#tag']].layout, criteria, found);
             }
           }
         });
index 569acf057f701713dc1e7e3c5be5c9b436f3f1d7..bc2014588bd410a389e1fd05278736025971f43c 100644 (file)
@@ -8,15 +8,15 @@
     bindings: {
       node: '='
     },
-    controller: function($scope, afAdmin) {
+    controller: function($scope, afGui) {
       var ts = $scope.ts = CRM.ts(),
         ctrl = this;
 
       $scope.getSetBackgroundColor = function(color) {
         if (!arguments.length) {
-          return afAdmin.getStyles(ctrl.node)['background-color'] || '#ffffff';
+          return afGui.getStyles(ctrl.node)['background-color'] || '#ffffff';
         }
-        afAdmin.setStyle(ctrl.node, 'background-color', color);
+        afGui.setStyle(ctrl.node, 'background-color', color);
       };
     }
   });
index c8b84cff6a28f14e2c4adb3a262dbbb75e765137..e22ec9c8479850a44362e2c53527b8c8036693fa 100644 (file)
@@ -8,7 +8,7 @@
     bindings: {
       node: '='
     },
-    controller: function($scope, afAdmin) {
+    controller: function($scope, afGui) {
       var ts = $scope.ts = CRM.ts(),
         ctrl = this;
 
           return border[idx];
         }
         border[idx] = val;
-        afAdmin.setStyle(node, 'border', val ? border.join(' ') : null);
+        afGui.setStyle(node, 'border', val ? border.join(' ') : null);
       }
 
       function getBorder(node) {
-        var border = _.map((afAdmin.getStyles(node).border || '').split(' '), _.trim);
+        var border = _.map((afGui.getStyles(node).border || '').split(' '), _.trim);
         return border.length > 2 ? border : null;
       }
     }
index 65eb081f60a534c2fe2257730c6a93c1d898a263..47773ef522507379e45c2a621c1adb6b3eb4cd46 100644 (file)
@@ -8,7 +8,7 @@
       node: '=',
       deleteThis: '&'
     },
-    controller: function($scope, afAdmin) {
+    controller: function($scope, afGui) {
       var ts = $scope.ts = CRM.ts(),
         ctrl = this;
 
       // Getter/setter for ng-model
       $scope.getSetStyle = function(val) {
         if (arguments.length) {
-          return afAdmin.modifyClasses(ctrl.node, _.keys($scope.styles), ['btn', val]);
+          return afGui.modifyClasses(ctrl.node, _.keys($scope.styles), ['btn', val]);
         }
-        return _.intersection(afAdmin.splitClass(ctrl.node['class']), _.keys($scope.styles))[0] || '';
+        return _.intersection(afGui.splitClass(ctrl.node['class']), _.keys($scope.styles))[0] || '';
       };
 
       $scope.pickIcon = function() {
-        afAdmin.pickIcon().then(function(val) {
+        afGui.pickIcon().then(function(val) {
           ctrl.node['crm-icon'] = val;
         });
       };
index 5fb23982da1f551d94066014b980e67c1ad8829b..7cf73a63f1f4d1b2a522f43caba4354eb521143c 100644 (file)
       deleteThis: '&'
     },
     require: {editor: '^^afGuiEditor'},
-    controller: function($scope, crmApi4, dialogService, afAdmin) {
+    controller: function($scope, crmApi4, dialogService, afGui) {
       var ts = $scope.ts = CRM.ts(),
         ctrl = this;
 
       this.$onInit = function() {
-        if ((ctrl.node['#tag'] in afAdmin.meta.blocks) || ctrl.join) {
+        if ((ctrl.node['#tag'] in afGui.meta.blocks) || ctrl.join) {
           initializeBlockContainer();
         }
       };
@@ -46,7 +46,7 @@
       };
 
       $scope.isRepeatable = function() {
-        return ctrl.node['af-fieldset'] || (block.directive && afAdmin.meta.blocks[block.directive].repeat) || ctrl.join;
+        return ctrl.node['af-fieldset'] || (block.directive && afGui.meta.blocks[block.directive].repeat) || ctrl.join;
       };
 
       $scope.toggleRepeat = function() {
@@ -92,7 +92,7 @@
       };
 
       $scope.pickAddIcon = function() {
-        afAdmin.pickIcon().then(function(val) {
+        afGui.pickIcon().then(function(val) {
           ctrl.node['add-icon'] = val;
         });
       };
         if (!ctrl.node) {
           return '';
         }
-        return _.intersection(afAdmin.splitClass(ctrl.node['class']), _.keys($scope.layouts))[0] || 'af-layout-rows';
+        return _.intersection(afGui.splitClass(ctrl.node['class']), _.keys($scope.layouts))[0] || 'af-layout-rows';
       };
 
       $scope.setLayout = function(val) {
         if (val !== 'af-layout-rows') {
           classes.push(val);
         }
-        afAdmin.modifyClasses(ctrl.node, _.keys($scope.layouts), classes);
+        afGui.modifyClasses(ctrl.node, _.keys($scope.layouts), classes);
       };
 
       $scope.selectBlockDirective = function() {
         if (block.directive) {
-          block.layout = _.cloneDeep(afAdmin.meta.blocks[block.directive].layout);
+          block.layout = _.cloneDeep(afGui.meta.blocks[block.directive].layout);
           block.original = block.directive;
           setBlockDirective(block.directive);
         }
           listeners: []
         };
 
-        _.each(afAdmin.meta.blocks, function(blockInfo, directive) {
+        _.each(afGui.meta.blocks, function(blockInfo, directive) {
           if (directive === ctrl.node['#tag'] || blockInfo.join === ctrl.getFieldEntityType()) {
             block.options.push({
               id: directive,
           }
         });
 
-        if (getBlockNode() && getBlockNode()['#tag'] in afAdmin.meta.blocks) {
+        if (getBlockNode() && getBlockNode()['#tag'] in afGui.meta.blocks) {
           block.directive = block.original = getBlockNode()['#tag'];
-          block.layout = _.cloneDeep(afAdmin.meta.blocks[block.directive].layout);
+          block.layout = _.cloneDeep(afGui.meta.blocks[block.directive].layout);
         }
 
         block.listeners.push($scope.$watch('block.layout', function (layout, oldVal) {
-          if (block.directive && layout && layout !== oldVal && !angular.equals(layout, afAdmin.meta.blocks[block.directive].layout)) {
+          if (block.directive && layout && layout !== oldVal && !angular.equals(layout, afGui.meta.blocks[block.directive].layout)) {
             overrideBlockContents(block.layout);
           }
         }, true));
           model.join = ctrl.join;
         }
         if ($scope.block && $scope.block.original) {
-          model.title = afAdmin.meta.blocks[$scope.block.original].title;
-          model.name = afAdmin.meta.blocks[$scope.block.original].name;
-          model.block = afAdmin.meta.blocks[$scope.block.original].block;
+          model.title = afGui.meta.blocks[$scope.block.original].title;
+          model.name = afGui.meta.blocks[$scope.block.original].name;
+          model.block = afGui.meta.blocks[$scope.block.original].block;
         }
         else {
           model.block = ctrl.container.getFieldEntityType() || '*';
         }
         dialogService.open('saveBlockDialog', '~/afGuiEditor/saveBlock.html', model, options)
           .then(function(block) {
-            afAdmin.meta.blocks[block.directive_name] = block;
+            afGui.meta.blocks[block.directive_name] = block;
             setBlockDirective(block.directive_name);
             initializeBlockContainer();
           });
         if (node['af-join']) {
           return 'join';
         }
-        if (node['#tag'] && node['#tag'] in afAdmin.meta.blocks) {
+        if (node['#tag'] && node['#tag'] in afGui.meta.blocks) {
           return 'container';
         }
-        var classes = afAdmin.splitClass(node['class']),
+        var classes = afGui.splitClass(node['class']),
           types = ['af-container', 'af-text', 'af-button', 'af-markup'],
           type = _.intersection(types, classes);
         return type.length ? type[0].replace('af-', '') : null;
       };
 
       this.removeElement = function(element) {
-        afAdmin.removeRecursive($scope.getSetChildren(), {$$hashKey: element.$$hashKey});
+        afGui.removeRecursive($scope.getSetChildren(), {$$hashKey: element.$$hashKey});
       };
 
       this.getEntityName = function() {
index d04dd5a96c44ad3060d38a2353d675881359ceef..107d4684b94b718f44b1b829a456c2e6ecab0cbc 100644 (file)
@@ -12,7 +12,7 @@
       editor: '^^afGuiEditor',
       container: '^^afGuiContainer'
     },
-    controller: function($scope, afAdmin) {
+    controller: function($scope, afGui) {
       var ts = $scope.ts = CRM.ts(),
         ctrl = this;
 
@@ -23,7 +23,7 @@
       ];
 
       this.$onInit = function() {
-        $scope.meta = afAdmin.meta;
+        $scope.meta = afGui.meta;
       };
 
       $scope.getEntity = function() {
@@ -31,7 +31,7 @@
       };
 
       $scope.getDefn = this.getDefn = function() {
-        return ctrl.editor ? afAdmin.getField(ctrl.container.getFieldEntityType(), ctrl.node.name) : {};
+        return ctrl.editor ? afGui.getField(ctrl.container.getFieldEntityType(), ctrl.node.name) : {};
       };
 
       $scope.hasOptions = function() {
index 8ce16894c1453697498c16f75cea3d6d022faaa5..6c045edd2f45385f9a2be1137c74bd09eea4a476 100644 (file)
@@ -8,7 +8,7 @@
       node: '=',
       deleteThis: '&'
     },
-    controller: function($scope, afAdmin) {
+    controller: function($scope, afGui) {
       var ts = $scope.ts = CRM.ts(),
         ctrl = this;
 
       };
 
       $scope.getAlign = function() {
-        return _.intersection(afAdmin.splitClass(ctrl.node['class']), _.keys($scope.alignments))[0] || 'text-left';
+        return _.intersection(afGui.splitClass(ctrl.node['class']), _.keys($scope.alignments))[0] || 'text-left';
       };
 
       $scope.setAlign = function(val) {
-        afAdmin.modifyClasses(ctrl.node, _.keys($scope.alignments), val === 'text-left' ? null : val);
+        afGui.modifyClasses(ctrl.node, _.keys($scope.alignments), val === 'text-left' ? null : val);
       };
 
       $scope.styles = _.transform(CRM.afGuiEditor.styles, function(styles, val, key) {
@@ -45,9 +45,9 @@
       // Getter/setter for ng-model
       $scope.getSetStyle = function(val) {
         if (arguments.length) {
-          return afAdmin.modifyClasses(ctrl.node, _.keys($scope.styles), val === 'text-default' ? null : val);
+          return afGui.modifyClasses(ctrl.node, _.keys($scope.styles), val === 'text-default' ? null : val);
         }
-        return _.intersection(afAdmin.splitClass(ctrl.node['class']), _.keys($scope.styles))[0] || 'text-default';
+        return _.intersection(afGui.splitClass(ctrl.node['class']), _.keys($scope.styles))[0] || 'text-default';
       };
 
     }