Rename `<af-model>` to `<af-entity>` to better match API terminology
authorTim Otten <totten@civicrm.org>
Sat, 14 Sep 2019 02:09:21 +0000 (22:09 -0400)
committerCiviCRM <info@civicrm.org>
Wed, 16 Sep 2020 02:13:19 +0000 (19:13 -0700)
ext/afform/auditor/backlog.md
ext/afform/core/CRM/Afform/ArrayHtml.php
ext/afform/core/Civi/Afform/Utils.php
ext/afform/core/afform.php
ext/afform/core/ang/af/Entity.js [moved from ext/afform/core/ang/af/Model.js with 71% similarity]
ext/afform/core/ang/afBlock/ContactName.html
ext/afform/docs/sandbox/planning-v0.3.md
ext/afform/docs/style.md
ext/afform/mock/ang/afex.aff.html
ext/afform/mock/ang/testAfform.aff.html

index ed5941e9760e971f365304f5c76e554185d71454..c5230b4150e9b48a2c1dfedff1bbe0b30fd07ae8 100644 (file)
@@ -7,8 +7,8 @@ validator to catch. Loosely/informally:
 
 * HTML partials should be well-formed/parseable XML
 * Warnings about any unrecognized tags/attributes/classes.
-* `<af-form>`, `<af-model>`, `<af-fieldset>`, `<af-field>` should have suitable relationships.
-* `<af-model>` should reference legit entities.
+* `<af-form>`, `<af-entity>`, `<af-fieldset>`, `<af-field>` should have suitable relationships.
+* `<af-entity>` should reference legit entities.
 * `<af-field>` should reference legit fields.
     * Future consideration: how to validate when it's part of a subform?
 * `<af-fieldset>` should reference a declared model.
index 7a4e7b76bd7a81b33f9fa8a81c4a63343e1493be..1839271f1691b32674ac567750642132792ae385 100644 (file)
@@ -21,7 +21,7 @@ class CRM_Afform_ArrayHtml {
     '*' => [
       '*' => 'text',
     ],
-    'af-model' => [
+    'af-entity' => [
       'name' => 'text',
       'type' => 'text',
       'data' => 'js',
@@ -158,7 +158,7 @@ class CRM_Afform_ArrayHtml {
    * Determine the type of data that is stored in an attribute.
    *
    * @param string $tag
-   *   Ex: 'af-model'
+   *   Ex: 'af-entity'
    * @param string $attrName
    *   Ex: 'label'
    * @return string
index d343894dc8bab6ccc6b743ee7d42a096017a2668..f8f4cc15053e9dcf4a188b37b00b56c203f2d9dd 100644 (file)
@@ -11,13 +11,13 @@ class Utils {
    * @return array
    */
   public static function getEntities($layout) {
-    $entities = array_column(self::getTags($layout, 'af-model'), NULL, 'name');
+    $entities = array_column(self::getTags($layout, 'af-entity'), NULL, 'name');
     self::getFields($layout, $entities);
     return $entities;
   }
 
   /**
-   * Returns all tags with a certain tag name, e.g. 'af-model'
+   * Returns all tags with a certain tag name, e.g. 'af-entity'
    *
    * @param array $collection
    * @param string $tagName
index ba3f5c2ec5b87f83d8a116f06af87c7a832fc255..28caaf8952e810fad97237d63052614fe322d328 100644 (file)
@@ -217,7 +217,7 @@ function afform_civicrm_alterAngular($angular) {
 
 function _afform_getMetadata(phpQueryObject $doc) {
   $entities = [];
-  foreach ($doc->find('af-model') as $afmModelProp) {
+  foreach ($doc->find('af-entity') as $afmModelProp) {
     $entities[$afmModelProp->getAttribute('name')] = [
       'type' => $afmModelProp->getAttribute('type'),
     ];
similarity index 71%
rename from ext/afform/core/ang/af/Model.js
rename to ext/afform/core/ang/af/Entity.js
index b7390a43ff83a9d48061c88f68055dfd10bfc013..561563d6cabff78c03f0f27788c5d99508c3d0a0 100644 (file)
@@ -1,7 +1,7 @@
 (function(angular, $, _) {
-  // "afModel" is a basic skeletal directive.
-  // Example usage: <af-form>... <af-model name="myModel" type="Individual" /> ...</af-form>
-  angular.module('af').directive('afModel', function() {
+  // "afEntity" is a basic skeletal directive.
+  // Example usage: <af-form>... <af-entity name="myModel" type="Individual" /> ...</af-form>
+  angular.module('af').directive('afEntity', function() {
     // Whitelist of all allowed properties of an af-fieldset
     // (at least the ones we care about client-side - other's can be added for server-side processing and we'll just ignore them)
     var modelProps = {
@@ -21,7 +21,7 @@
         entity.id = null;
         entity.fields = [];
         afFormCtrl.registerEntity(entity);
-        // $scope.$watch('afModel', function(newValue){$scope.myOptions = newValue;});
+        // $scope.$watch('afEntity', function(newValue){$scope.myOptions = newValue;});
       }
     };
   });
index 541edcc84dfdbb1c6f18c9d127a2cb4d73c7ab58..3a345a33221de1e27a6e5eac71557374a7df0fea 100644 (file)
@@ -1 +1,8 @@
-<div>{{ts('Contact name block for a model of type %1 named %2', {1: afFieldset.getDefn().type, 2: afFieldset.getDefn().modelName})}}</div>
+<af-form>
+  <af-entity name="$parent.model" type="Contact" label="Target Contact" />
+  <af-fieldset model="$parent.model">
+    <af-field name="prefix" />
+    <af-field name="first_name" />
+    <af-field name="last_name" />
+  </af-fieldset>
+</af-form>
index cce1eb46016784fa27426a25a0617334f9a4287e..2273a4b889880bc39e8622fa63a3bad5839e4cb2 100644 (file)
 
 ```html
 <af-form ctrl="modelListCtrl">
-  <af-model
+  <af-entity
     type="Individual"
     name="parent"
     label="Parent"
     api4-params="{where: ['id','=', routeParams.cid]}"
   />
-  <af-model
+  <af-entity
     type="Individual"
     name="spouse"
     label="Spouse"
 <!-- input: options.parent.id -->
 <!-- Decision: These blocks are written in straight AngularJS rather than Afform -->
 <!--<af-form>-->
-  <!--<af-model -->
+  <!--<af-entity -->
     <!--type="Email"-->
     <!--name="email"-->
     <!--label="Emails"-->
 
 ```html
 <af-form ctrl="modelListCtrl">
-  <af-model
+  <af-entity
     type="Individual"
     name="parent"
     label="Parent"
     api4-params="{where: ['id','=', routeParams.cid]}"
   />
-  <af-model
+  <af-entity
     type="Individual"
     name="spouse"
     label="Spouse"
index 58736e8ccdc4e358ecc615b362f84c9f9ee06189..5b9fb38abd72bdcb2525d1d8bbe8cf7ad9f89a05 100644 (file)
@@ -4,10 +4,10 @@
 
 The following naming conventions apply to directives defined within `afform.git`:
 
-* Standalone directives (e.g. `afModel` or `afField`), including forms (e.g. `afHtmlEditor`)
+* Standalone directives (e.g. `afEntity` or `afField`), including forms (e.g. `afHtmlEditor`)
     * The directive name must begin with the `af` prefix.
     * Supplemental attributes SHOULD NOT begin with the `af` prefix.
-    * Example: `<af-model type="Activity" name="myPhoneCall">`
+    * Example: `<af-entity type="Activity" name="myPhoneCall">`
 
 * Mix-in directives (e.g. `afMonaco` or `afApi4Action`)
     * The directive name must begin with the `af` prefix.
@@ -18,7 +18,7 @@ __Discussion__: These differ in two ways:
 
 * Namespacing
     * Standalone directives form an implicit namespace.
-      (*Anything passed to `<af-model>` is implicitly about `af-model`.)
+      (*Anything passed to `<af-entity>` is implicitly about `af-entity`.)
     * Mix-in directives must share a namespace with other potential mix-ins.
       (*The *)
 * Directive arguments
index 8596e3877b7c017804a61ed4e7152cf5c6861f96..f81aff3c5fd7d9c26da200a1fff4059bbcd57ae1 100644 (file)
@@ -1,8 +1,8 @@
 <af-form ctrl="modelListCtrl">
   <!-- FIXME: Distinguish "Individual"s from "Household"s -->
-  <af-model type="Contact" name="parent" label="Parent" api4-params="{where: ['id','=', routeParams.cid]}" />
-  <af-model type="Contact" name="spouse" label="Spouse" contact-relationship="['Spouse of', 'parent']" />
-  <af-model type="Contact" name="home" label="Home" />
+  <af-entity type="Contact" name="parent" label="Parent" api4-params="{where: ['id','=', routeParams.cid]}" />
+  <af-entity type="Contact" name="spouse" label="Spouse" contact-relationship="['Spouse of', 'parent']" />
+  <af-entity type="Contact" name="home" label="Home" />
 
   <!-- "parent" and "spouse" should be exported as variables in this scope -->
 
index add785cd58248d1432106232cc9d5769a653555f..50acb5062c2f1e2eddc2cb5ec63c20ee48737d5e 100644 (file)
@@ -1,9 +1,9 @@
 <af-form ctrl="modelListCtrl" >
   <div crm-ui-debug="modelListCtrl.getEntity('parent')" />
   <div crm-ui-debug="modelListCtrl.getData('parent')" />
-  <af-model type="Contact" data="{contact_type: 'Individual'}" name="parent" label="Parent" url-autofill="1" autofill="user" />
-  <af-model type="Contact" name="spouse" label="Spouse" url-autofill="1" />
-  <af-model type="Contact" name="home" label="Home" />
+  <af-entity type="Contact" data="{contact_type: 'Individual'}" name="parent" label="Parent" url-autofill="1" autofill="user" />
+  <af-entity type="Contact" name="spouse" label="Spouse" url-autofill="1" />
+  <af-entity type="Contact" name="home" label="Home" />
 
   <af-fieldset model="parent">