* 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.
'*' => [
'*' => 'text',
],
- 'af-model' => [
+ 'af-entity' => [
'name' => 'text',
'type' => 'text',
'data' => 'js',
* 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
* @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
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'),
];
(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 = {
entity.id = null;
entity.fields = [];
afFormCtrl.registerEntity(entity);
- // $scope.$watch('afModel', function(newValue){$scope.myOptions = newValue;});
+ // $scope.$watch('afEntity', function(newValue){$scope.myOptions = newValue;});
}
};
});
-<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>
```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"
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.
* 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
<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 -->
<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">