From bbd6df21b235ecda950c3c069c58a6562c19c027 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 12 Sep 2019 22:07:56 -0400 Subject: [PATCH] Rename af-type to type --- ext/afform/core/Civi/Api4/Action/Afform/Prefill.php | 6 +++--- ext/afform/core/Civi/Api4/Action/Afform/Submit.php | 2 +- ext/afform/core/afform.php | 4 ++-- ext/afform/core/ang/af/ModelProp.js | 4 ++-- ext/afform/core/ang/afBlock/ContactEmail.html | 2 +- ext/afform/core/ang/afBlock/ContactName.html | 2 +- ext/afform/mock/ang/afex.aff.html | 6 +++--- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ext/afform/core/Civi/Api4/Action/Afform/Prefill.php b/ext/afform/core/Civi/Api4/Action/Afform/Prefill.php index 64ff21822f..b8babb67d7 100644 --- a/ext/afform/core/Civi/Api4/Action/Afform/Prefill.php +++ b/ext/afform/core/Civi/Api4/Action/Afform/Prefill.php @@ -37,14 +37,14 @@ class Prefill extends AbstractProcessor { */ private function loadEntity($entity, $id) { $checkPermissions = TRUE; - if ($entity['af-type'] == 'Contact' && !empty($this->args[$entity['af-name'] . '-cs'])) { + if ($entity['type'] == 'Contact' && !empty($this->args[$entity['af-name'] . '-cs'])) { $checkSum = civicrm_api4('Contact', 'validateChecksum', [ 'checksum' => $this->args[$entity['af-name'] . '-cs'], 'contactId' => $id, ]); $checkPermissions = empty($checkSum[0]['valid']); } - $result = civicrm_api4($entity['af-type'], 'get', [ + $result = civicrm_api4($entity['type'], 'get', [ 'where' => [['id', '=', $id]], 'select' => array_column($entity['fields'], 'field-name'), 'checkPermissions' => $checkPermissions, @@ -62,7 +62,7 @@ class Prefill extends AbstractProcessor { */ private function autoFillEntity($entity, $mode) { $id = NULL; - if ($entity['af-type'] == 'Contact') { + if ($entity['type'] == 'Contact') { if ($mode == 'user') { $id = \CRM_Core_Session::getLoggedInContactID(); } diff --git a/ext/afform/core/Civi/Api4/Action/Afform/Submit.php b/ext/afform/core/Civi/Api4/Action/Afform/Submit.php index 94241a121f..be9546c471 100644 --- a/ext/afform/core/Civi/Api4/Action/Afform/Submit.php +++ b/ext/afform/core/Civi/Api4/Action/Afform/Submit.php @@ -23,7 +23,7 @@ class Submit extends AbstractProcessor { protected function processForm() { foreach ($this->_afformEntities as $entityName => $entity) { // Predetermined values override submitted values - $this->_submission[$entity['af-type']][$entityName] = ($entity['af-values'] ?? []) + ($this->values[$entityName] ?? []); + $this->_submission[$entity['type']][$entityName] = ($entity['af-values'] ?? []) + ($this->values[$entityName] ?? []); } // Determines the order in which to process entities. Contacts go first. $entitiesToProcess = [ diff --git a/ext/afform/core/afform.php b/ext/afform/core/afform.php index c505c3c426..b4314e90a4 100644 --- a/ext/afform/core/afform.php +++ b/ext/afform/core/afform.php @@ -182,7 +182,7 @@ function afform_civicrm_alterAngular($angular) { foreach (pq('af-field', $doc) as $afField) { /** @var DOMElement $afField */ $fieldName = $afField->getAttribute('field-name'); - $entityName = pq($afField)->parent('[af-name]')->attr('af-name'); + $entityName = pq($afField)->parent('af-model[af-name]')->attr('af-name'); // TEST ME if (!preg_match(';^[a-zA-Z0-9\_\-\. ]+$;', $entityName)) { throw new \CRM_Core_Exception("Cannot process $path: malformed entity name ($entityName)"); } @@ -216,7 +216,7 @@ function _afform_getMetadata(phpQueryObject $doc) { $entities = []; foreach ($doc->find('af-model-prop') as $afmModelProp) { $entities[$afmModelProp->getAttribute('af-name')] = [ - 'type' => $afmModelProp->getAttribute('af-type'), + 'type' => $afmModelProp->getAttribute('type'), ]; } return $entities; diff --git a/ext/afform/core/ang/af/ModelProp.js b/ext/afform/core/ang/af/ModelProp.js index 7bf5b45418..2d36e81b06 100644 --- a/ext/afform/core/ang/af/ModelProp.js +++ b/ext/afform/core/ang/af/ModelProp.js @@ -1,11 +1,11 @@ (function(angular, $, _) { // "afModelProp" is a basic skeletal directive. - // Example usage: ... ... + // Example usage: ... ... angular.module('af').directive('afModelProp', function() { // Whitelist of all allowed properties of an af-model // (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 = { - afType: '@', + type: '@', afData: '=', afName: '@', afLabel: '@', diff --git a/ext/afform/core/ang/afBlock/ContactEmail.html b/ext/afform/core/ang/afBlock/ContactEmail.html index b40b6bec6b..41aab8b722 100644 --- a/ext/afform/core/ang/afBlock/ContactEmail.html +++ b/ext/afform/core/ang/afBlock/ContactEmail.html @@ -1 +1 @@ -
{{ts('Contact email block for a model of type %1 named %2', {1: afModel.getDefn().afType, 2: afModel.getDefn().afName})}}
+
{{ts('Contact email block for a model of type %1 named %2', {1: afModel.getDefn().type, 2: afModel.getDefn().afName})}}
diff --git a/ext/afform/core/ang/afBlock/ContactName.html b/ext/afform/core/ang/afBlock/ContactName.html index 9a18f57841..08b62db246 100644 --- a/ext/afform/core/ang/afBlock/ContactName.html +++ b/ext/afform/core/ang/afBlock/ContactName.html @@ -1 +1 @@ -
{{ts('Contact name block for a model of type %1 named %2', {1: afModel.getDefn().afType, 2: afModel.getDefn().afName})}}
+
{{ts('Contact name block for a model of type %1 named %2', {1: afModel.getDefn().type, 2: afModel.getDefn().afName})}}
diff --git a/ext/afform/mock/ang/afex.aff.html b/ext/afform/mock/ang/afex.aff.html index 2bf4552669..5d112bb96b 100644 --- a/ext/afform/mock/ang/afex.aff.html +++ b/ext/afform/mock/ang/afex.aff.html @@ -1,8 +1,8 @@ - - - + + + -- 2.25.1