From 05887e05932dfbeb6f0945f804290ab33d4fea8b Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Tue, 28 Jan 2025 10:58:30 +0200 Subject: [PATCH 01/12] Save petition attribute collection data Save form and display.php render phpv8.2 deprecation Petition preview parse people picker value Petition Preview new structure Add collapsable behavior fix people link Fix disabled fields. Fix affiliation_type petition render. More improvements Fixing Petition resume view --- .../AttributeCollectorsController.php | 17 +++- .../Model/Table/AttributeCollectorsTable.php | 24 ++++- .../Model/Table/PetitionAttributesTable.php | 1 + .../CoreEnroller/src/config/plugin.json | 3 +- .../templates/AttributeCollectors/display.php | 8 ++ .../templates/EnrollmentAttributes/fields.inc | 3 +- .../CoreEnroller/templates/element/field.php | 2 +- .../element/mveas/fieldset-field.php | 30 ++++++ app/src/Model/Table/PetitionsTable.php | 6 +- app/src/View/Helper/FieldHelper.php | 2 +- app/src/View/Helper/PetitionHelper.php | 1 + app/templates/Petitions/fields.inc | 38 ++++---- .../element/petition/enrollmentFlowStep.php | 40 ++++++++ .../attributeCollectorsStep.php | 91 +++++++++++++++++++ app/webroot/css/co-base.css | 15 +++ app/webroot/js/comanage/comanage.js | 27 ++++++ 16 files changed, 276 insertions(+), 32 deletions(-) create mode 100644 app/plugins/CoreEnroller/templates/AttributeCollectors/display.php create mode 100644 app/templates/element/petition/enrollmentFlowStep.php create mode 100644 app/templates/element/petition/enrollmentFlowSteps/attributeCollectorsStep.php diff --git a/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php index 27faa2749..7665edb2d 100644 --- a/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php @@ -30,9 +30,9 @@ namespace CoreEnroller\Controller; use App\Controller\StandardEnrollerController; -use App\Lib\Enum\PetitionStatusEnum; use Cake\Event\EventInterface; use Cake\Http\Response; +use Cake\ORM\TableRegistry; class AttributeCollectorsController extends StandardEnrollerController { public $paginate = [ @@ -125,12 +125,19 @@ public function dispatch(string $id) { /** * Display information about this Step. * - * @since COmanage Registry v5.0.0 + * @since COmanage Registry v5.1.0 * @param string $id Attribute Collector ID */ - public function display(string $id) { - debug("display something for this petition"); - debug($this->getPetition()); + public function display(string $id): void { + $petition = $this->getPetition(); + + $this->set('vv_petition_attributes', + $this->AttributeCollectors + ->EnrollmentAttributes + ->PetitionAttributes + ->find() + ->where(['petition_id' => $petition->id]) + ->all()); } } diff --git a/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php b/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php index 18e3c22e9..bd5b1d27a 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php @@ -166,15 +166,33 @@ public function upsert(int $id, int $petitionId, array $attributes) { foreach($attributes as $enrollmentAttributeLabel => $value) { // Remove field- prefix from the form field name - $enrollmentAttributeId = (int)substr($enrollmentAttributeLabel, 6); + $fieldToParts = explode('-', $enrollmentAttributeLabel); + // MVAs have multiple columns. For example a name has: + // given, surname, prefix, ... + $columnName = null; + if (count($fieldToParts) > 2) { + // There is a type ID in the middle + $columnName = $fieldToParts[1]; + } + // The enrollment Attribute ID is the last part + $enrollmentAttributeId = (int)array_pop($fieldToParts); + + // The people picker will send a complex string and not just the id. We need to extract it ourselves. + $re = '/^.*\(ID: (\d+)\)$/m'; + preg_match_all($re, $value, $matches, PREG_SET_ORDER, 0); + if(!empty($matches)) { + $value = $matches[0][1]; + } $newAttribute = [ 'petition_id' => $petitionId, 'enrollment_attribute_id' => $enrollmentAttributeId, - 'value' => $value + 'value' => $value, + // This is the column name for the attributes that consist of multiple fields, like the name or the address + 'column_name' => $columnName, ]; - if(array_key_exists($enrollmentAttributeId, $currentAttributes)) { + if(\array_key_exists($enrollmentAttributeId, $currentAttributes)) { // This is an update of an existing attribute $newAttribute['id'] = $currentAttributes[$enrollmentAttributeId]; diff --git a/app/plugins/CoreEnroller/src/Model/Table/PetitionAttributesTable.php b/app/plugins/CoreEnroller/src/Model/Table/PetitionAttributesTable.php index 161d873eb..d26329d5f 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/PetitionAttributesTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/PetitionAttributesTable.php @@ -103,6 +103,7 @@ public function validationDefault(Validator $validator): Validator { $validator->notEmptyString('enrollment_attribute_id'); $this->registerStringValidation($validator, $schema, 'value', false); + $this->registerStringValidation($validator, $schema, 'column', false); return $validator; } diff --git a/app/plugins/CoreEnroller/src/config/plugin.json b/app/plugins/CoreEnroller/src/config/plugin.json index dbb666b8a..bb58ddb56 100644 --- a/app/plugins/CoreEnroller/src/config/plugin.json +++ b/app/plugins/CoreEnroller/src/config/plugin.json @@ -111,7 +111,8 @@ "id": {}, "petition_id": {}, "enrollment_attribute_id": { "type": "integer", "foreignkey": { "table": "enrollment_attributes", "column": "id" } }, - "value": { "type": "string", "size": 160 } + "value": { "type": "string", "size": 160 }, + "column_name": { "notnull": false, "type": "string", "size": 64 } }, "indexes": { "petition_attributes_i1": { "columns": [ "petition_id" ] }, diff --git a/app/plugins/CoreEnroller/templates/AttributeCollectors/display.php b/app/plugins/CoreEnroller/templates/AttributeCollectors/display.php new file mode 100644 index 000000000..f25efb457 --- /dev/null +++ b/app/plugins/CoreEnroller/templates/AttributeCollectors/display.php @@ -0,0 +1,8 @@ +toArray(); +?> + diff --git a/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc b/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc index 0ea015f21..09a3a971d 100644 --- a/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc +++ b/app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc @@ -32,8 +32,7 @@ use \Cake\Utility\Inflector; $attribute_type = null; if($vv_action == 'add') { $attribute_type = $this->request->getQuery('attribute_type'); -} else if($vv_action == 'edit' && !empty($vv_obj) -) { +} else if($vv_action == 'edit' && !empty($vv_obj)) { $attribute_type = $vv_obj->attribute; } diff --git a/app/plugins/CoreEnroller/templates/element/field.php b/app/plugins/CoreEnroller/templates/element/field.php index b5cd48d5a..80a3b8cd4 100644 --- a/app/plugins/CoreEnroller/templates/element/field.php +++ b/app/plugins/CoreEnroller/templates/element/field.php @@ -119,5 +119,5 @@ 'formArguments' => $formArguments ]), // Default use case - default => $this->element('form/listItem', ['arguments' => $formArguments]) + default => $this->Field->getElementsForDisabledInput('form/listItem', $formArguments) }; diff --git a/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php b/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php index 58c89298c..4a1624761 100644 --- a/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php +++ b/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php @@ -38,12 +38,39 @@ $isRequiredFromValidationRule = false; $supportedAttributes = $this->Petition->getSupportedEnrollmentAttribute($attr->attribute); +// Field Options array +$options = []; + if(isset($supportedAttributes['mveaModel'])) { $supportedAttributes = $this->Petition->getSupportedEnrollmentAttribute($attr->attribute); $modelTable = $this->Petition->getTable($supportedAttributes['mveaModel']); $isRequiredFromValidationRule = !$modelTable->getValidator()->field($field)->isEmptyAllowed(); } +// Do we have a default value configured? +// Either a value or an Environmental Variable, +// Each default value is mutually exclusive to the rest. We do not have to worry about a conflict. +$options['default'] = match(true) { + isset($attr->default_value) => $attr->default_value, + isset($attr->default_value_env_name) + && getenv($attr->default_value_env_name) !== false => getenv($attr->default_value_env_name), + isset($attr->default_value_datetime) => $attr->default_value_datetime, + default => '' +}; + +// If we are re-rendering the Petition, override the default value with whatever +// was previously saved +if(!empty($vv_petition_attributes)) { + $curEntity = $vv_petition_attributes->firstMatch([ + 'enrollment_attribute_id' => $attr->id, + 'column_name' => $field + ]); + + if(!empty($curEntity->value)) { + $options['default'] = $curEntity->value; + } +} + // Construct the field arguments $formArguments = [ // We prefix the attribute ID with a string because Cake seems to sometimes have @@ -53,6 +80,9 @@ 'fieldType' => $modelTable->getSchema()->getColumn($field)['type'], 'fieldNameAlias' => $attr->attribute // the field name to its enrollment attribute field name ]; + +// Set the final fieldOptions +$formArguments['fieldOptions'] = $options; ?>
"> diff --git a/app/src/Model/Table/PetitionsTable.php b/app/src/Model/Table/PetitionsTable.php index fd760387e..e999b7d80 100644 --- a/app/src/Model/Table/PetitionsTable.php +++ b/app/src/Model/Table/PetitionsTable.php @@ -90,6 +90,9 @@ public function initialize(array $config): void { $this->hasMany('PetitionStepResults') ->setDependent(true) ->setCascadeCallbacks(true); + $this->hasMany('PetitionAttributes') + ->setDependent(true) + ->setCascadeCallbacks(true); $this->hasOne('Verifications') ->setDependent(true) @@ -116,7 +119,8 @@ public function initialize(array $config): void { 'EnrolleePeople' => ['PrimaryName' => ['foreignKey' => 'person_id']], 'PetitionerPeople' => ['PrimaryName' => ['foreignKey' => 'person_id']], 'PetitionHistoryRecords', - 'PetitionStepResults' + 'PetitionStepResults', + 'PetitionAttributes', ]); $this->setAutoViewVars([ diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index 4a221150c..34ca57ce3 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -304,7 +304,7 @@ public function dateField(string $fieldName, isset($fieldArgs['default']) && is_string($fieldArgs['default']) => FrozenTime::parse($fieldArgs['default']), // Petition View/ Value saved a FronzenTime isset($fieldArgs['default']) - && is_a($fieldArgs['default'], 'Cake\I18n\FrozenTime') => $fieldArgs['default'], + && is_a($fieldArgs['default'], 'Cake\I18n\FrozenTime') => $fieldArgs['default'], // Table record/ Retrieve it from the Entity object default => $this->getEntity()?->$fieldName, }; diff --git a/app/src/View/Helper/PetitionHelper.php b/app/src/View/Helper/PetitionHelper.php index 0f1ddec59..a23edf2e0 100644 --- a/app/src/View/Helper/PetitionHelper.php +++ b/app/src/View/Helper/PetitionHelper.php @@ -35,6 +35,7 @@ use Cake\Utility\Inflector; use Cake\View\Helper; use CoreEnroller\Model\Table\EnrollmentAttributesTable; +use DOMDocument; class PetitionHelper extends Helper { diff --git a/app/templates/Petitions/fields.inc b/app/templates/Petitions/fields.inc index 1665c1682..a0a0cb007 100644 --- a/app/templates/Petitions/fields.inc +++ b/app/templates/Petitions/fields.inc @@ -230,35 +230,37 @@ if (!empty($vv_obj?->petitioner_person?->id)) { - enrollment_flow->enrollment_flow_steps as $step): ?> - petition_step_results, "{n}[enrollment_flow_step_id=$step->id]"); - - if(!empty($result)) { - $resultLink = [ - 'controller' => 'petitions', - 'action' => 'result', - $vv_obj->id, - '?' => [ - 'enrollment_flow_step_id' => $step->id - ] - ]; - } - ?> - + petition_step_results, "{n}[enrollment_flow_step_id=$step->id]"); ?>
  • - description ?> + description ?>
    - Html->link($result[0]->comment, $resultLink) : "" ?> + comment : '' ?> +
  • +
  • +

    + +

    + element('petition/enrollmentFlowStep', ['vv_step' => $step])?> +
  • diff --git a/app/templates/element/petition/enrollmentFlowStep.php b/app/templates/element/petition/enrollmentFlowStep.php new file mode 100644 index 000000000..afc898b70 --- /dev/null +++ b/app/templates/element/petition/enrollmentFlowStep.php @@ -0,0 +1,40 @@ +plugin); +$modelName = array_pop($parsePluginName); +$elementName = lcfirst($modelName) . 'Step'; + +// The convention is that the element name for each step is the name of the EnrollmentFlow Step model followed by +// the word Step +print $this->element("petition/enrollmentFlowSteps/$elementName", ['vv_step' => $vv_step]); diff --git a/app/templates/element/petition/enrollmentFlowSteps/attributeCollectorsStep.php b/app/templates/element/petition/enrollmentFlowSteps/attributeCollectorsStep.php new file mode 100644 index 000000000..9ff02c4e3 --- /dev/null +++ b/app/templates/element/petition/enrollmentFlowSteps/attributeCollectorsStep.php @@ -0,0 +1,91 @@ +petition_attributes, '{n}.enrollment_attribute_id'); +$vv_enrollment_atttributes_ids = array_unique($vv_enrollment_atttributes_ids); + +$enrollmentAttributesTable = $this->Petition->getTable('EnrollmentAttributes'); +$vv_enrollment_attributes = $enrollmentAttributesTable->find() + ->where(fn(QueryExpression $exp, Query $q) => $exp->in('id', $vv_enrollment_atttributes_ids)) + ->toArray(); + +?> + + diff --git a/app/webroot/css/co-base.css b/app/webroot/css/co-base.css index 92584f03f..799fa3b08 100644 --- a/app/webroot/css/co-base.css +++ b/app/webroot/css/co-base.css @@ -1001,6 +1001,21 @@ ul.form-list li.alert-banner .co-alert { white-space: nowrap; margin-right: 0.5em; } +/* PETITION PREVIEW */ +a.cm-toggle { + float: right; + border: none; + background-color: transparent; +} +a.cm-toggle .material-symbols, +a.cm-toggle .material-symbols-outlined{ + color: var(--cmg-color-headings); +} +a.cm-toggle .material-symbols, +a.cm-toggle .material-symbols-outlined { + font-size: 34px; + line-height: 17px; +} /* PLATFORM NOTICE (for COmanage CO) */ #platform-notice { padding: 0.5em; diff --git a/app/webroot/js/comanage/comanage.js b/app/webroot/js/comanage/comanage.js index dd8b88aba..a15bea941 100644 --- a/app/webroot/js/comanage/comanage.js +++ b/app/webroot/js/comanage/comanage.js @@ -423,4 +423,31 @@ function setApplicationState(value, elem, reload= false) { generateFlash("" + errorThrown + " (" + jqXHR.status + ")", 'error') } }); +} + +function stepCollapseTongle(event, item) { + /** + * Toggles the expanded or collapsed state of the step element. + * + * This function prevents the default action and stops the propagation of the event, + * then toggles the "collapsed" class for the given element. It also updates + * the `aria-expanded` attribute and changes the icon displayed within the element. + * + * - If the element is collapsed, it sets `aria-expanded` to "false" and updates + * the icon to "arrow_drop_down." + * - If the element is expanded, it sets `aria-expanded` to "true" and updates + * the icon to "arrow_drop_up." + * + * @param {Event} event - The event triggered, usually by a click action. + * @param {HTMLElement} item - The DOM element being toggled that represents the step. + */ + event.preventDefault(); + event.stopPropagation(); + if ($(item).hasClass("collapsed")) { + $(item).attr("aria-expanded","false") + $(item).find('em').text("arrow_drop_down"); + } else { + $(item).attr("aria-expanded","true") + $(item).find('em').text("arrow_drop_up"); + } } \ No newline at end of file From 9b56f1344cc1484b939bc26f7ffaec3e334c229f Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Tue, 4 Feb 2025 16:38:33 +0200 Subject: [PATCH 02/12] Fix access to array item --- .../enrollmentFlowSteps/attributeCollectorsStep.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/templates/element/petition/enrollmentFlowSteps/attributeCollectorsStep.php b/app/templates/element/petition/enrollmentFlowSteps/attributeCollectorsStep.php index 9ff02c4e3..82165c3e1 100644 --- a/app/templates/element/petition/enrollmentFlowSteps/attributeCollectorsStep.php +++ b/app/templates/element/petition/enrollmentFlowSteps/attributeCollectorsStep.php @@ -56,9 +56,9 @@ if(!empty($value) && str_ends_with($attribute->attribute, 'person_id')) { // We need to load the associated model data $associatedModel = $this->Petition->getRecordForId('person_id', $attr->value, ['PrimaryName']); - $value = $associatedModel[0]->primary_name->given . ' ' - . $associatedModel[0]->primary_name->family . ' ' - . '(ID: ' . $associatedModel[0]->id . ')'; + $value = $associatedModel['primary_name']['given'] . ' ' + . $associatedModel['primary_name']['family'] . ' ' + . '(ID: ' . $associatedModel['id'] . ')'; $value = $this->Html->link($value, ['controller' => 'people', 'action' => 'edit', $attr->value]); } elseif(!empty($value) && str_ends_with($attribute->attribute, '_id')) { From bcc4cf9ac4641fe8e0e98bc4eb44cb73eae06c86 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Tue, 4 Feb 2025 18:29:13 +0200 Subject: [PATCH 03/12] Fix, partially, the AttributeCollectors finalize function. --- .../Model/Table/AttributeCollectorsTable.php | 34 +++++++++++++------ .../Table/BasicAttributeCollectorsTable.php | 2 +- .../element/mveas/fieldset-field.php | 2 ++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php b/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php index bd5b1d27a..03ecee815 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php @@ -29,6 +29,7 @@ namespace CoreEnroller\Model\Table; +use App\Model\Entity\Petition; use Cake\Datasource\ConnectionManager; use Cake\ORM\Query; use Cake\ORM\RulesChecker; @@ -117,21 +118,32 @@ public function initialize(array $config): void { /** * Perform steps necessary to finalize the Petition. - * - * @since COmanage Registry v5.0.0 - * @param int $id Attribute Collector ID - * @param int $petitionId Petition ID + * + * @param int $id Attribute Collector ID + * @param Petition $petition * @return bool true on success + * @since COmanage Registry v5.1.0 */ - public function finalize(int $id, int $petitionId) { -// XXX convert Petition Attributes to operational Attributes -// keep in mind this can be called multiple times if the plugin is -// instantiated more than once in the Enrollment Flow ($id will be different) -// any errors should be logged or otherwise managed, returning false -// or throwing an error will NOT prevent the petition from finalizing + public function finalize(int $id, \App\Model\Entity\Petition $petition) { + $cfg = $this->get($id); + + if(empty($petition->enrollee_person_id)) { + throw new \InvalidArgumentException(__d('error', 'Petitions.enrollee.notfound', [$petition->id])); + } + + $People = TableRegistry::getTableLocator()->get('People'); + + $person = $People->get($petition->enrollee_person_id); + + $attributes = $this->EnrollmentAttributes + ->PetitionAttributes + ->find() + ->where(['petition_id' => $petition->id]) + ->firstOrFail(); -debug("in AttributeCollector finalize"); + // XXX Should i save the primary name? + // XXX Should i save the email? return true; } diff --git a/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php b/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php index cd0ac0766..5fa748580 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php @@ -147,7 +147,7 @@ public function finalize(int $id, \App\Model\Entity\Petition $petition) { // At this point there is a Person record allocated and stored in the Petition, // but it doesn't have any attributes on it, including a Primary Name. // We assume we're the only attribute collector, so we'll force a Primary Name - // based on the Basic Attribtues, and create a skeletal role. + // based on the Basic Attributes, and create a skeletal role. if(empty($petition->enrollee_person_id)) { throw new \InvalidArgumentException(__d('error', 'Petitions.enrollee.notfound', [$petition->id])); diff --git a/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php b/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php index 4a1624761..e8e7e53e6 100644 --- a/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php +++ b/app/plugins/CoreEnroller/templates/element/mveas/fieldset-field.php @@ -52,6 +52,8 @@ // Each default value is mutually exclusive to the rest. We do not have to worry about a conflict. $options['default'] = match(true) { isset($attr->default_value) => $attr->default_value, + // XXX The $attr->default_value_env_name for the name attribute is tricky. Since the name has many values. + // Check the EnvSource plugin isset($attr->default_value_env_name) && getenv($attr->default_value_env_name) !== false => getenv($attr->default_value_env_name), isset($attr->default_value_datetime) => $attr->default_value_datetime, From a9cfa0c95e2d545fca1fffe18937d6c635f9f9cf Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Tue, 4 Feb 2025 20:30:33 +0200 Subject: [PATCH 04/12] Fix miscalculated tab link process --- app/src/View/Helper/TabHelper.php | 54 +++++++++++++++++++ .../element/subnavigation/supertitle.php | 24 +++++---- 2 files changed, 69 insertions(+), 9 deletions(-) diff --git a/app/src/View/Helper/TabHelper.php b/app/src/View/Helper/TabHelper.php index 9bc78da51..71f314295 100644 --- a/app/src/View/Helper/TabHelper.php +++ b/app/src/View/Helper/TabHelper.php @@ -63,6 +63,8 @@ class TabHelper extends Helper public function constructLinkUrl(string $tab, string|int $curId, bool $isNested = false): array { $curController = $this->getView()->getRequest()->getParam('controller'); + $vv_associated_ids = $this->getView()->get('vv_associated_ids'); + $modelName = $tab; $controller = $modelName; $plugin = null; @@ -100,7 +102,15 @@ public function constructLinkUrl(string $tab, string|int $curId, bool $isNested ]; if ($action === 'index') { + $deepId = $this->getDeepNestedId($linkFilter); + If($deepId !== null) { + $linkFilterForeignKey = array_key_first($linkFilter); + $linkFilter[$linkFilterForeignKey] = $deepId; + } $url['?'] = $linkFilter; + } else if ($action === 'edit') { + // I will get the id from the associated ids table + $url[] = $vv_associated_ids[$controller]; } else { $url[] = $curId; } @@ -108,6 +118,49 @@ public function constructLinkUrl(string $tab, string|int $curId, bool $isNested return $url; } + + /** + * Retrieve the ID for a deeply nested association. + * + * @param array $linkFilter The link filter containing foreign key details. + * + * @return int|null The ID of the deeply nested associated model or null if not found. + * @since COmanage Registry v5.1.0 + */ + public function getDeepNestedId(array $linkFilter): ?int + { + $vv_associated_ids = $this->getView()->get('vv_associated_ids'); + + // Get the foreign from the linkFilter + $linkFilterForeignKey = array_key_first($linkFilter); + // Generate the ModelName and instantiate the linked Table + $modelName = StringUtilities::foreignKeyToClassName($linkFilterForeignKey); + $table = TableRegistry::getTableLocator()->get($modelName); + $linkFilterId = $vv_associated_ids[Inflector::pluralize($modelName)] ?? null; + if($linkFilterId !== null) { + return (int)$linkFilterId; + } + $foreignKeyId = -1; + $foreignKey = null; + // This means that we are working on deep nested associations and we need + // to fetch more data + $linkFilterSchema = $table->getSchema(); + foreach($linkFilterSchema->columns() as $column) { + // Check the foreign keys + if(str_ends_with($column, '_id')) { + $foreignKeytToTableName = Inflector::pluralize(StringUtilities::foreignKeyToClassName($column)); + if(isset($vv_associated_ids[$foreignKeytToTableName])) { + $foreignKeyId = $vv_associated_ids[$foreignKeytToTableName]; + $foreignKey = $column; + break; + } + } + } + $id = $table->find()->where([$foreignKey => $foreignKeyId])->first()->id; + + return(int)$id; + } + /** * Calculate the link Class * @@ -205,6 +258,7 @@ public function getCurrentId(string $tabName = null, bool $isNested = false): in TableUtilities::treeTraversalFromId($curController, (int)$tid, $results); } + $this->getView()->set('vv_associated_ids', $results); $tabAction = $this->getTabAction($tabName, $isNested); if( diff --git a/app/templates/element/subnavigation/supertitle.php b/app/templates/element/subnavigation/supertitle.php index b5f238df3..840d09547 100644 --- a/app/templates/element/subnavigation/supertitle.php +++ b/app/templates/element/subnavigation/supertitle.php @@ -65,16 +65,22 @@ && $vv_subnavigation_tabs[0] !== StringUtilities::entityToClassName($vv_bc_parent_obj) ) { $object = $vv_obj ?? $$objectName?->first(); - // If we get here, it means that neither the request object nor its parent can give us a supertitle. - // We need to fetch all the ids and get the supertitle from the root tab/node - $results = []; - TableUtilities::treeTraversalFromId(StringUtilities::entityToClassName($object), (int)$object->id, $results); - $superTitleModelReference = $this->Tab->getModelTableReference($vv_subnavigation_tabs[0]); - $superTitleModelDisplayField = $superTitleModelReference->getDisplayField(); - $superTitleModelId = $results[$vv_subnavigation_tabs[0]]; + if ($object === null) { + // This is a deep nested association that has not been initialized yet. The controller name + // will become the supertitle + $vv_subnavigation_tabsSupertitle = Inflector::humanize($vv_controller); + } else { + // If we get here, it means that neither the request object nor its parent can give us a supertitle. + // We need to fetch all the ids and get the supertitle from the root tab/node + $results = []; + TableUtilities::treeTraversalFromId(StringUtilities::entityToClassName($object), (int)$object->id, $results); + $superTitleModelReference = $this->Tab->getModelTableReference($vv_subnavigation_tabs[0]); + $superTitleModelDisplayField = $superTitleModelReference->getDisplayField(); + $superTitleModelId = $results[$vv_subnavigation_tabs[0]]; - $root_obj = $superTitleModelReference->get($superTitleModelId); - $vv_subnavigation_tabsSupertitle = $root_obj->$superTitleModelDisplayField; + $root_obj = $superTitleModelReference->get($superTitleModelId); + $vv_subnavigation_tabsSupertitle = $root_obj->$superTitleModelDisplayField; + } } $supertitle = match (true) { From fc72caaabcbe5533dd6b2c7a2fc5230488a8ca3a Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Wed, 5 Feb 2025 10:42:31 +0200 Subject: [PATCH 05/12] Rename view variable creating conflict --- app/src/Controller/MVEAController.php | 6 +++--- app/templates/element/subnavigation.php | 10 +++++----- app/templates/element/subnavigation/statusBadge.php | 2 +- app/templates/element/subnavigation/supertitle.php | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/Controller/MVEAController.php b/app/src/Controller/MVEAController.php index 52fb641c7..4a7ec6507 100644 --- a/app/src/Controller/MVEAController.php +++ b/app/src/Controller/MVEAController.php @@ -100,7 +100,7 @@ public function beforeFilter(\Cake\Event\EventInterface $event) { $personName = $Names->primaryName($externalIdentity->person_id); $this->set('vv_person_name', $personName); $this->set('vv_supertitle', $personName->full_name); - $this->set('vv_person_id', $externalIdentity->person_id); + $this->set('vv_mvea_person_id', $externalIdentity->person_id); break; case 'person_role_id': $PersonRoles = $this->getTableLocator()->get('PersonRoles'); @@ -113,13 +113,13 @@ public function beforeFilter(\Cake\Event\EventInterface $event) { $personName = $Names->primaryName($roleEntity->person_id); $this->set('vv_person_name', $personName); $this->set('vv_supertitle', $personName->full_name); - $this->set('vv_person_id', $roleEntity->person_id); + $this->set('vv_mvea_person_id', $roleEntity->person_id); break; case 'person_id': $personName = $Names->primaryName((int)$primaryLink->value); $this->set('vv_person_name', $personName); $this->set('vv_supertitle', $personName->full_name); - $this->set('vv_person_id', $primaryLink->value); + $this->set('vv_mvea_person_id', $primaryLink->value); break; default; break; diff --git a/app/templates/element/subnavigation.php b/app/templates/element/subnavigation.php index 138d38e38..cd453a966 100644 --- a/app/templates/element/subnavigation.php +++ b/app/templates/element/subnavigation.php @@ -42,9 +42,9 @@ $curId = $this->request->getQuery($vv_primary_link); $linkFilter = [$vv_primary_link => $curId]; // For top-level nav - if(!empty($vv_person_id)) { - $curId = $vv_person_id; - $linkFilter = ['person_id' => $vv_person_id]; + if(!empty($vv_mvea_person_id)) { + $curId = $vv_mvea_person_id; + $linkFilter = ['person_id' => $vv_mvea_person_id]; } } elseif (!empty($vv_obj)) { // This will work for most top-level edit views @@ -55,8 +55,8 @@ // these have been explicitly set in the $subnav array in fields-nav.inc, so just use them. $curId = $tabsId; $navController = $tabsController; - } elseif(!empty($vv_person_id)) { - $curId = $vv_person_id; + } elseif(!empty($vv_mvea_person_id)) { + $curId = $vv_mvea_person_id; } elseif( ($active == 'plugin' || (!empty($vv_primary_link) && $vv_primary_link == 'enrollment_flow_id')) && !empty($vv_primary_link_obj) diff --git a/app/templates/element/subnavigation/statusBadge.php b/app/templates/element/subnavigation/statusBadge.php index 16a0ae5ab..1cd6f6cb6 100644 --- a/app/templates/element/subnavigation/statusBadge.php +++ b/app/templates/element/subnavigation/statusBadge.php @@ -35,7 +35,7 @@ return; } -$personId = $vv_person_id +$personId = $vv_mvea_person_id ?? $this->request->getQuery('person_id') ?? $vv_obj?->person_id ?? $vv_obj?->id; diff --git a/app/templates/element/subnavigation/supertitle.php b/app/templates/element/subnavigation/supertitle.php index 840d09547..c7354fa47 100644 --- a/app/templates/element/subnavigation/supertitle.php +++ b/app/templates/element/subnavigation/supertitle.php @@ -38,7 +38,7 @@ * Person with deep nested dependency */ -$person_id = (int)($vv_person_id ?? $vv_obj?->person_id ?? $this->getRequest()->getQuery('person_id')); +$person_id = (int)($vv_mvea_person_id ?? $vv_obj?->person_id ?? $this->getRequest()->getQuery('person_id')); if ($person_id) { $personFullName = $this->Tab->getPersonPrimaryName($person_id); } From 67545bb4add33c208c0f23f28efb33f68b842afa Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Wed, 5 Feb 2025 12:44:31 +0200 Subject: [PATCH 06/12] Fix attribute conflict.Fix BasicAttributesCollector dispaly. --- .../AttributeCollectorsController.php | 19 ----------- .../BasicAttributeCollectorsController.php | 17 ---------- .../templates/AttributeCollectors/display.php | 8 ----- .../BasicAttributeCollectors/display.php | 8 ----- .../petition}/attributeCollectorsStep.php | 0 .../basicAttributeCollectorsStep.php} | 33 +++++++++++-------- app/src/Model/Table/PetitionsTable.php | 2 +- app/src/View/Helper/PetitionHelper.php | 2 +- app/templates/Petitions/fields.inc | 11 ++++--- 9 files changed, 29 insertions(+), 71 deletions(-) delete mode 100644 app/plugins/CoreEnroller/templates/AttributeCollectors/display.php delete mode 100644 app/plugins/CoreEnroller/templates/BasicAttributeCollectors/display.php rename app/{templates/element/petition/enrollmentFlowSteps => plugins/CoreEnroller/templates/element/petition}/attributeCollectorsStep.php (100%) rename app/{templates/element/petition/enrollmentFlowStep.php => plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php} (55%) diff --git a/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php index 7665edb2d..7e1631bd3 100644 --- a/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/AttributeCollectorsController.php @@ -121,23 +121,4 @@ public function dispatch(string $id) { $this->render('/Standard/dispatch'); } - - /** - * Display information about this Step. - * - * @since COmanage Registry v5.1.0 - * @param string $id Attribute Collector ID - */ - - public function display(string $id): void { - $petition = $this->getPetition(); - - $this->set('vv_petition_attributes', - $this->AttributeCollectors - ->EnrollmentAttributes - ->PetitionAttributes - ->find() - ->where(['petition_id' => $petition->id]) - ->all()); - } } diff --git a/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php index bf3f701f8..01890e70f 100644 --- a/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php @@ -87,21 +87,4 @@ public function dispatch(string $id) { $this->render('/Standard/dispatch'); } - - /** - * Display information about this Step. - * - * @since COmanage Registry v5.1.0 - * @param string $id Attribute Collector ID - */ - - public function display(string $id) { - $petition = $this->getPetition(); - - $this->set('vv_petition_basic_attribute_set', $this->BasicAttributeCollectors - ->PetitionBasicAttributeSets - ->find() - ->where(['PetitionBasicAttributeSets.petition_id' => $petition->id]) - ->firstOrFail()); - } } diff --git a/app/plugins/CoreEnroller/templates/AttributeCollectors/display.php b/app/plugins/CoreEnroller/templates/AttributeCollectors/display.php deleted file mode 100644 index f25efb457..000000000 --- a/app/plugins/CoreEnroller/templates/AttributeCollectors/display.php +++ /dev/null @@ -1,8 +0,0 @@ -toArray(); -?> -
      - -
    • ID: id?>, Value: value?>, Column Name: column_name ?>
    • - -
    diff --git a/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/display.php b/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/display.php deleted file mode 100644 index 4247e7400..000000000 --- a/app/plugins/CoreEnroller/templates/BasicAttributeCollectors/display.php +++ /dev/null @@ -1,8 +0,0 @@ -
      -
    • Honorific:
    • -
    • Given:
    • -
    • Middle:
    • -
    • Family:
    • -
    • Suffix:
    • -
    • Email:
    • -
    diff --git a/app/templates/element/petition/enrollmentFlowSteps/attributeCollectorsStep.php b/app/plugins/CoreEnroller/templates/element/petition/attributeCollectorsStep.php similarity index 100% rename from app/templates/element/petition/enrollmentFlowSteps/attributeCollectorsStep.php rename to app/plugins/CoreEnroller/templates/element/petition/attributeCollectorsStep.php diff --git a/app/templates/element/petition/enrollmentFlowStep.php b/app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php similarity index 55% rename from app/templates/element/petition/enrollmentFlowStep.php rename to app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php index afc898b70..925999d9a 100644 --- a/app/templates/element/petition/enrollmentFlowStep.php +++ b/app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php @@ -1,6 +1,6 @@ id === null) { + return __d('error', 'notfound', 'Petition Attributes'); + } -$parsePluginName = explode('.', $vv_step->plugin); -$modelName = array_pop($parsePluginName); -$elementName = lcfirst($modelName) . 'Step'; + $tableObj = $this->Petition->getTable('PetitionBasicAttributeSets'); + $vv_petition_basic_attribute_set = $tableObj->find() + ->where(['PetitionBasicAttributeSets.petition_id' => $vv_obj->id]) + ->firstOrFail(); +?> -// The convention is that the element name for each step is the name of the EnrollmentFlow Step model followed by -// the word Step -print $this->element("petition/enrollmentFlowSteps/$elementName", ['vv_step' => $vv_step]); +
      +
    • Honorific:
    • +
    • Given:
    • +
    • Middle:
    • +
    • Family:
    • +
    • Suffix:
    • +
    • Email:
    • +
    diff --git a/app/src/Model/Table/PetitionsTable.php b/app/src/Model/Table/PetitionsTable.php index e999b7d80..065ab20ef 100644 --- a/app/src/Model/Table/PetitionsTable.php +++ b/app/src/Model/Table/PetitionsTable.php @@ -90,7 +90,7 @@ public function initialize(array $config): void { $this->hasMany('PetitionStepResults') ->setDependent(true) ->setCascadeCallbacks(true); - $this->hasMany('PetitionAttributes') + $this->hasMany('CoreEnroller.PetitionAttributes') ->setDependent(true) ->setCascadeCallbacks(true); diff --git a/app/src/View/Helper/PetitionHelper.php b/app/src/View/Helper/PetitionHelper.php index a23edf2e0..be426a30d 100644 --- a/app/src/View/Helper/PetitionHelper.php +++ b/app/src/View/Helper/PetitionHelper.php @@ -83,7 +83,7 @@ public function populateAutoViewVars(): void } /** - * Get the table validation rules + * Get reference to the Table Object * * @param string $tableName * diff --git a/app/templates/Petitions/fields.inc b/app/templates/Petitions/fields.inc index a0a0cb007..ee38c5183 100644 --- a/app/templates/Petitions/fields.inc +++ b/app/templates/Petitions/fields.inc @@ -256,10 +256,13 @@ if (!empty($vv_obj?->petitioner_person?->id)) {
  • -

    - -

    - element('petition/enrollmentFlowStep', ['vv_step' => $step])?> +

    plugin ?>

    + plugin); + $elementName = lcfirst($pluginClass) . 'Step'; + + print $this->element("$pluginName.petition/$elementName", ['vv_step' => $step]); + ?>
  • From 9901933e325c5feb4dff200882863bbb2415d5a7 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Wed, 5 Feb 2025 16:51:31 +0200 Subject: [PATCH 07/12] Render hidden column for Enrollment Attributes --- .../CoreEnroller/templates/EnrollmentAttributes/columns.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/plugins/CoreEnroller/templates/EnrollmentAttributes/columns.inc b/app/plugins/CoreEnroller/templates/EnrollmentAttributes/columns.inc index 26fcceba5..2a4a83c39 100644 --- a/app/plugins/CoreEnroller/templates/EnrollmentAttributes/columns.inc +++ b/app/plugins/CoreEnroller/templates/EnrollmentAttributes/columns.inc @@ -49,6 +49,10 @@ $indexColumns = [ 'required' => [ 'type' => 'boolean', 'class' => 'YesBooleanEnum' + ], + 'hidden' => [ + 'type' => 'boolean', + 'class' => 'YesBooleanEnum' ] ]; From e122d16460fe003b0dfc1538a2032d743923b7cf Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Wed, 5 Feb 2025 19:19:56 +0200 Subject: [PATCH 08/12] Move display.php to elements --- .../Controller/EmailVerifiersController.php | 21 ------------ .../IdentifierCollectorsController.php | 15 --------- .../InvitationAcceptersController.php | 15 --------- .../templates/EmailVerifiers/display.php | 24 -------------- .../IdentifierCollectors/display.php | 4 --- .../element/petition/emailVerifiersStep.php | 32 +++++++++++++++++++ .../petition/identifierCollectorsStep.php | 8 +++++ .../petition/invitationAcceptersStep.php} | 4 +++ 8 files changed, 44 insertions(+), 79 deletions(-) delete mode 100644 app/plugins/CoreEnroller/templates/EmailVerifiers/display.php delete mode 100644 app/plugins/CoreEnroller/templates/IdentifierCollectors/display.php create mode 100644 app/plugins/CoreEnroller/templates/element/petition/emailVerifiersStep.php create mode 100644 app/plugins/CoreEnroller/templates/element/petition/identifierCollectorsStep.php rename app/plugins/CoreEnroller/templates/{InvitationAccepters/display.php => element/petition/invitationAcceptersStep.php} (65%) diff --git a/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php b/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php index c79f21e43..35595ccd6 100644 --- a/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php +++ b/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php @@ -216,25 +216,4 @@ public function dispatch(string $id) { $this->render('/Standard/dispatch'); } - - /** - * Display information about this Step. - * - * @since COmanage Registry v5.1.0 - * @param string $id Email Verifiers ID - */ - - public function display(string $id) { - $petition = $this->getPetition(); - - $PetitionVerifications = TableRegistry::getTableLocator()->get('CoreEnroller.PetitionVerifications'); - - // Because Petition Verifications are not tracked on a per-step basis, we just pull all - // associated with the Petition - - $this->set('vv_pv', $PetitionVerifications->find() - ->where(['PetitionVerifications.petition_id' => $petition->id]) - ->contain(['Verifications']) - ->all()); - } } \ No newline at end of file diff --git a/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php index 9b0fe090e..be0e63cf6 100644 --- a/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/IdentifierCollectorsController.php @@ -96,21 +96,6 @@ public function dispatch(string $id) { } } - /** - * Display information about this Step. - * - * @since COmanage Registry v5.1.0 - * @param string $id Invitation Accepters ID - */ - - public function display(string $id) { - $petition = $this->getPetition(); - - $PetitionIdentifiers = TableRegistry::getTableLocator()->get('CoreEnroller.PetitionIdentifiers'); - - $this->set('vv_pi', $PetitionIdentifiers->find()->where(['petition_id' => $petition->id])->first()); - } - /** * Indicate whether this Controller will handle some or all authnz. * diff --git a/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php b/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php index d6b91802b..90d05ba78 100644 --- a/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php +++ b/app/plugins/CoreEnroller/src/Controller/InvitationAcceptersController.php @@ -133,19 +133,4 @@ public function dispatch(string $id) { $this->render('/Standard/dispatch'); } - - /** - * Display information about this Step. - * - * @since COmanage Registry v5.1.0 - * @param string $id Invitation Accepters ID - */ - - public function display(string $id) { - $petition = $this->getPetition(); - - $PetitionAcceptances = TableRegistry::getTableLocator()->get('CoreEnroller.PetitionAcceptances'); - - $this->set('vv_pa', $PetitionAcceptances->find()->where(['petition_id' => $petition->id])->first()); - } } diff --git a/app/plugins/CoreEnroller/templates/EmailVerifiers/display.php b/app/plugins/CoreEnroller/templates/EmailVerifiers/display.php deleted file mode 100644 index a3aded80a..000000000 --- a/app/plugins/CoreEnroller/templates/EmailVerifiers/display.php +++ /dev/null @@ -1,24 +0,0 @@ -\n"; - - foreach($vv_pv as $pv) { - print "
  • " . $pv->mail . ": "; - - if(!empty($pv->verification) && $pv->verification->isVerified()) { - print __d('result', 'Verifications.status', [ - VerificationMethodEnum::getLocalization($pv->verification->method), - $this->Time->nice($pv->verification->verification_time, $vv_tz) - ]); - } else { - print __d('field', 'unverified'); - } - - print "
  • "; - } - - print "\n"; -} \ No newline at end of file diff --git a/app/plugins/CoreEnroller/templates/IdentifierCollectors/display.php b/app/plugins/CoreEnroller/templates/IdentifierCollectors/display.php deleted file mode 100644 index 30359a605..000000000 --- a/app/plugins/CoreEnroller/templates/IdentifierCollectors/display.php +++ /dev/null @@ -1,4 +0,0 @@ -identifier)) { - print __d('core_enroller', 'result.IdentifierCollector.collected', [$vv_pi->identifier]); -} diff --git a/app/plugins/CoreEnroller/templates/element/petition/emailVerifiersStep.php b/app/plugins/CoreEnroller/templates/element/petition/emailVerifiersStep.php new file mode 100644 index 000000000..8e1aec591 --- /dev/null +++ b/app/plugins/CoreEnroller/templates/element/petition/emailVerifiersStep.php @@ -0,0 +1,32 @@ +Petition->getTable('CoreEnroller.PetitionVerifications'); + +// Because Petition Verifications are not tracked on a per-step basis, we just pull all +// associated with the Petition + +$vv_pv = $PetitionVerifications->find() + ->where(['PetitionVerifications.petition_id' => $vv_obj->id]) + ->contain(['Verifications']) + ->all(); + +?> + + +
      + +
    • mail ?>: + verification) && $pv->verification->isVerified()): ?> + verification->method), + $this->Time->nice($pv->verification->verification_time, $vv_tz) + ]) ?> + + ?> + +
    • + +
    + \ No newline at end of file diff --git a/app/plugins/CoreEnroller/templates/element/petition/identifierCollectorsStep.php b/app/plugins/CoreEnroller/templates/element/petition/identifierCollectorsStep.php new file mode 100644 index 000000000..f486c6e19 --- /dev/null +++ b/app/plugins/CoreEnroller/templates/element/petition/identifierCollectorsStep.php @@ -0,0 +1,8 @@ +Petition->getTable('CoreEnroller.PetitionIdentifiers'); + +$vv_pi = $PetitionIdentifiers->find()->where(['petition_id' => $vv_obj->id])->first(); + +if(!empty($vv_pi->identifier)) { + print __d('core_enroller', 'result.IdentifierCollector.collected', [$vv_pi->identifier]); +} \ No newline at end of file diff --git a/app/plugins/CoreEnroller/templates/InvitationAccepters/display.php b/app/plugins/CoreEnroller/templates/element/petition/invitationAcceptersStep.php similarity index 65% rename from app/plugins/CoreEnroller/templates/InvitationAccepters/display.php rename to app/plugins/CoreEnroller/templates/element/petition/invitationAcceptersStep.php index d1d911100..08ca25823 100644 --- a/app/plugins/CoreEnroller/templates/InvitationAccepters/display.php +++ b/app/plugins/CoreEnroller/templates/element/petition/invitationAcceptersStep.php @@ -1,4 +1,8 @@ Petition->getTable('CoreEnroller.PetitionAcceptances'); + +$vv_pa = $PetitionAcceptances->find()->where(['petition_id' => $vv_obj->id])->first(); + if(!empty($vv_pa)) { if($vv_pa['accepted']) { print __d('core_enroller', 'result.InvitationAccepters.accepted', [$vv_pa['modified']]); From 11668dd11254731f47d8e478a8f3602e43dbec9d Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Wed, 5 Feb 2025 20:48:15 +0200 Subject: [PATCH 09/12] basic attribute collectors view refactor --- .../petition/basicAttributeCollectorsStep.php | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php b/app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php index 925999d9a..18f8cdb66 100644 --- a/app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php +++ b/app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php @@ -38,10 +38,48 @@ ?>
      -
    • Honorific:
    • -
    • Given:
    • -
    • Middle:
    • -
    • Family:
    • -
    • Suffix:
    • -
    • Email:
    • +
    • +

      Full Name

      +
        +
      • +
        honorific
        +
        +
      • +
      • +
        + given +
        +
        + +
        +
      • +
      • +
        + +
        +
        +
        +
      • +
      • +
        + family +
        +
        + +
        +
      • +
      • +
        + suffix +
        +
        + +
        +
      • +
      +
    • +
    • +

      Email Address

      +
      +
    From b7898ab69c4cf56b7395ffcdffc9f28ee5387a92 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Wed, 5 Feb 2025 21:05:23 +0200 Subject: [PATCH 10/12] Fix enrollment attributes ordering --- .../templates/element/petition/attributeCollectorsStep.php | 1 + .../templates/element/petition/basicAttributeCollectorsStep.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/plugins/CoreEnroller/templates/element/petition/attributeCollectorsStep.php b/app/plugins/CoreEnroller/templates/element/petition/attributeCollectorsStep.php index 82165c3e1..0293a519f 100644 --- a/app/plugins/CoreEnroller/templates/element/petition/attributeCollectorsStep.php +++ b/app/plugins/CoreEnroller/templates/element/petition/attributeCollectorsStep.php @@ -42,6 +42,7 @@ $enrollmentAttributesTable = $this->Petition->getTable('EnrollmentAttributes'); $vv_enrollment_attributes = $enrollmentAttributesTable->find() ->where(fn(QueryExpression $exp, Query $q) => $exp->in('id', $vv_enrollment_atttributes_ids)) + ->order(['ordr' => 'ASC']) ->toArray(); ?> diff --git a/app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php b/app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php index 18f8cdb66..f546d294d 100644 --- a/app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php +++ b/app/plugins/CoreEnroller/templates/element/petition/basicAttributeCollectorsStep.php @@ -36,7 +36,6 @@ ->where(['PetitionBasicAttributeSets.petition_id' => $vv_obj->id]) ->firstOrFail(); ?> -