From d16b39c3c687d68900fba7d090693ea27ea6bc2c Mon Sep 17 00:00:00 2001
From: Coleman Watts
Date: Wed, 30 Oct 2019 20:33:26 -0400
Subject: [PATCH] Restrict af-fieldset directive to A not E
The af-fieldset directive was ambiguiously set to restrict: "AE"
but only "E" was supported. I want to pick one and stick with it, and
I prefer "A" because the fieldset is also a container, so div or fieldset
seem like the appropriate tag names.
---
ext/afform/core/Civi/Afform/FormDataModel.php | 4 +--
ext/afform/core/afform.php | 2 +-
ext/afform/core/ang/af/Fieldset.js | 6 ++--
ext/afform/core/ang/afBlock/ContactName.html | 4 +--
ext/afform/core/ang/afBlock/ContactName.js | 1 -
ext/afform/core/ang/afField/afField.js | 2 +-
.../phpunit/Civi/Afform/FormDataModelTest.php | 2 +-
ext/afform/docs/sandbox/planning-v0.3.md | 34 +++++++++----------
ext/afform/mock/ang/afex.aff.html | 16 ++++-----
ext/afform/mock/ang/testAfform.aff.html | 8 ++---
10 files changed, 39 insertions(+), 40 deletions(-)
diff --git a/ext/afform/core/Civi/Afform/FormDataModel.php b/ext/afform/core/Civi/Afform/FormDataModel.php
index 8b783f4bfc..5055e14cf8 100644
--- a/ext/afform/core/Civi/Afform/FormDataModel.php
+++ b/ext/afform/core/Civi/Afform/FormDataModel.php
@@ -57,8 +57,8 @@ class FormDataModel {
if (is_string($child)) {
//nothing
}
- elseif ($child['#tag'] == 'af-fieldset' && !empty($child['#children'])) {
- $entities[$child['model']]['fields'] = array_merge($entities[$child['model']]['fields'] ?? [], AHQ::getTags($child, 'af-field'));
+ elseif (!empty($child['af-fieldset']) && !empty($child['#children'])) {
+ $entities[$child['af-fieldset']]['fields'] = array_merge($entities[$child['af-fieldset']]['fields'] ?? [], AHQ::getTags($child, 'af-field'));
}
else {
self::parseFields($child, $entities);
diff --git a/ext/afform/core/afform.php b/ext/afform/core/afform.php
index c4ea5305fa..b1d41f5a84 100644
--- a/ext/afform/core/afform.php
+++ b/ext/afform/core/afform.php
@@ -310,7 +310,7 @@ function afform_civicrm_alterAngular($angular) {
foreach (pq('af-field', $doc) as $afField) {
/** @var DOMElement $afField */
$fieldName = $afField->getAttribute('name');
- $entityName = pq($afField)->parent('af-fieldset[model]')->attr('model');
+ $entityName = pq($afField)->parent('[af-fieldset]')->attr('af-fieldset');
if (!preg_match(';^[a-zA-Z0-9\_\-\. ]+$;', $entityName)) {
throw new \CRM_Core_Exception("Cannot process $path: malformed entity name ($entityName)");
}
diff --git a/ext/afform/core/ang/af/Fieldset.js b/ext/afform/core/ang/af/Fieldset.js
index 72e6e5481d..63e338554d 100644
--- a/ext/afform/core/ang/af/Fieldset.js
+++ b/ext/afform/core/ang/af/Fieldset.js
@@ -1,12 +1,12 @@
(function(angular, $, _) {
// "afFieldset" is a basic skeletal directive.
- // Example usage: ... ... ...
+ // Example usage: ... ...
...
angular.module('af').directive('afFieldset', function() {
return {
- restrict: 'AE',
+ restrict: 'A',
require: '^afForm',
scope: {
- modelName: '@model'
+ modelName: '@afFieldset'
},
link: function($scope, $el, $attr, afFormCtrl) {
$scope.afFormCtrl = afFormCtrl;
diff --git a/ext/afform/core/ang/afBlock/ContactName.html b/ext/afform/core/ang/afBlock/ContactName.html
index 3a345a3322..8585c9b824 100644
--- a/ext/afform/core/ang/afBlock/ContactName.html
+++ b/ext/afform/core/ang/afBlock/ContactName.html
@@ -1,8 +1,8 @@
-
+
diff --git a/ext/afform/core/ang/afBlock/ContactName.js b/ext/afform/core/ang/afBlock/ContactName.js
index 46cb104419..2de0136783 100644
--- a/ext/afform/core/ang/afBlock/ContactName.js
+++ b/ext/afform/core/ang/afBlock/ContactName.js
@@ -1,5 +1,4 @@
(function(angular, $, _) {
- // Example usage:
angular.module('afBlock').directive('afBlockContactName', function() {
return {
restrict: 'AE',
diff --git a/ext/afform/core/ang/afField/afField.js b/ext/afform/core/ang/afField/afField.js
index 4a3c9b1a96..6c70a98e70 100644
--- a/ext/afform/core/ang/afField/afField.js
+++ b/ext/afform/core/ang/afField/afField.js
@@ -1,5 +1,5 @@
(function(angular, $, _) {
- // Example usage:
+ // Example usage:
angular.module('afField').directive('afField', function() {
return {
restrict: 'E',
diff --git a/ext/afform/core/tests/phpunit/Civi/Afform/FormDataModelTest.php b/ext/afform/core/tests/phpunit/Civi/Afform/FormDataModelTest.php
index 52e32fab2c..b75619d8ef 100644
--- a/ext/afform/core/tests/phpunit/Civi/Afform/FormDataModelTest.php
+++ b/ext/afform/core/tests/phpunit/Civi/Afform/FormDataModelTest.php
@@ -39,7 +39,7 @@ class FormDataModelTest extends \PHPUnit\Framework\TestCase implements HeadlessI
];
$cases[] = [
- 'html' => '
',
+ 'html' => '',
'entities' => [
'foobar' => [
'type' => 'Foo',
diff --git a/ext/afform/docs/sandbox/planning-v0.3.md b/ext/afform/docs/sandbox/planning-v0.3.md
index 2273a4b889..18b33073cf 100644
--- a/ext/afform/docs/sandbox/planning-v0.3.md
+++ b/ext/afform/docs/sandbox/planning-v0.3.md
@@ -68,16 +68,16 @@
-
+
-
+
-
+
```
@@ -100,23 +100,23 @@
/>
-
+
-
+
Your spouse should go to the gym.
-
+
@@ -137,9 +137,9 @@
-
+
-
+
```
@@ -164,18 +164,18 @@
-
+
-
+
@@ -183,9 +183,9 @@
Your spouse should go to the gym.
-
+
diff --git a/ext/afform/mock/ang/afex.aff.html b/ext/afform/mock/ang/afex.aff.html
index f81aff3c5f..1cc0a26dbd 100644
--- a/ext/afform/mock/ang/afex.aff.html
+++ b/ext/afform/mock/ang/afex.aff.html
@@ -6,25 +6,25 @@
-
+
-
+
-
+
-
+
diff --git a/ext/afform/mock/ang/testAfform.aff.html b/ext/afform/mock/ang/testAfform.aff.html
index a8fecdb4f3..824054eb4c 100644
--- a/ext/afform/mock/ang/testAfform.aff.html
+++ b/ext/afform/mock/ang/testAfform.aff.html
@@ -4,7 +4,7 @@
-
+
About You
@@ -13,15 +13,15 @@
-
+
-
+
--
2.25.1