From 26a5f33e0952875b372450c268e4478ef889787e Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Sat, 15 Feb 2025 18:45:19 +0200 Subject: [PATCH] Fix enrollment flow step ux (#300) --- .../BasicAttributeCollectorsController.php | 22 ++++++++++++++++++- .../Table/BasicAttributeCollectorsTable.php | 19 +++++++++++++++- .../Model/Table/EnrollmentFlowStepsTable.php | 4 +++- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php b/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php index 01890e70f..285a7fb9b 100644 --- a/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php +++ b/app/plugins/CoreEnroller/src/Controller/BasicAttributeCollectorsController.php @@ -31,7 +31,6 @@ use Cake\ORM\TableRegistry; use App\Controller\StandardEnrollerController; -use App\Lib\Enum\PetitionStatusEnum; class BasicAttributeCollectorsController extends StandardEnrollerController { public $paginate = [ @@ -40,6 +39,27 @@ class BasicAttributeCollectorsController extends StandardEnrollerController { ] ]; + /** + * Callback run prior to the request render. + * + * @param EventInterface $event Cake Event + * + * @return Response|void + * @since COmanage Registry v5.1.0 + */ + + public function beforeRender(\Cake\Event\EventInterface $event) { + $link = $this->getPrimaryLink(true); + + if(!empty($link->value)) { + $this->set('vv_bc_parent_obj', $this->BasicAttributeCollectors->EnrollmentFlowSteps->get($link->value)); + $this->set('vv_bc_parent_displayfield', $this->BasicAttributeCollectors->EnrollmentFlowSteps->getDisplayField()); + $this->set('vv_bc_parent_primarykey', $this->BasicAttributeCollectors->EnrollmentFlowSteps->getPrimaryKey()); + } + + return parent::beforeRender($event); + } + /** * Dispatch an Enrollment Flow Step. * diff --git a/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php b/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php index a1aced150..0a99fa869 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/BasicAttributeCollectorsTable.php @@ -42,10 +42,11 @@ class BasicAttributeCollectorsTable extends Table { use \App\Lib\Traits\AutoViewVarsTrait; use \App\Lib\Traits\CoLinkTrait; - use \App\Lib\Traits\LayoutTrait; use \App\Lib\Traits\LabeledLogTrait; + use \App\Lib\Traits\LayoutTrait; use \App\Lib\Traits\PermissionsTrait; use \App\Lib\Traits\PrimaryLinkTrait; + use \App\Lib\Traits\TabTrait; use \App\Lib\Traits\TableMetaTrait; use \App\Lib\Traits\ValidationTrait; @@ -91,6 +92,22 @@ public function initialize(array $config): void { $this->setRequiresCO(true); $this->setAllowLookupPrimaryLink(['dispatch', 'display']); + // All the tabs share the same configuration in the ModelTable file + $this->setTabsConfig( + [ + // Ordered list of Tabs + 'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.BasicAttributeCollectors'], + // What actions will include the subnavigation header + 'action' => [ + // If a model renders in a subnavigation mode in edit/view mode, it cannot + // render in index mode for the same use case/context + // XXX edit should go first. + 'EnrollmentFlowSteps' => ['edit', 'view'], + 'CoreEnroller.BasicAttributeCollectors' => ['edit'], + ] + ] + ); + $this->setAutoViewVars([ 'affiliationTypes' => [ 'type' => 'type', diff --git a/app/src/Model/Table/EnrollmentFlowStepsTable.php b/app/src/Model/Table/EnrollmentFlowStepsTable.php index 99f359388..3de024281 100644 --- a/app/src/Model/Table/EnrollmentFlowStepsTable.php +++ b/app/src/Model/Table/EnrollmentFlowStepsTable.php @@ -77,6 +77,7 @@ public function initialize(array $config): void { $this->setPrimaryLink('enrollment_flow_id'); $this->setRequiresCO(true); $this->setRedirectGoal('self'); + $this->setRedirectGoal(action: 'delete', goal: 'deleted'); $this->setAutoViewVars([ 'actorTypes' => [ @@ -110,7 +111,8 @@ public function initialize(array $config): void { // Actions that operate over a table (ie: do not require an $id) 'table' => [ 'add' => ['platformAdmin', 'coAdmin'], - 'index' => ['platformAdmin', 'coAdmin'] + 'index' => ['platformAdmin', 'coAdmin'], + 'deleted' => ['platformAdmin', 'coAdmin'] ], 'related' => [ 'table' => [