From 530887efa73e7370627a9a5256a19e9b23e229b1 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Thu, 26 Sep 2024 22:18:54 +0300 Subject: [PATCH] feature-cfm31-subnavigation (#217) * Group to tabs element * enrollment flows tabs * Person to tabs * Missing tabs code * Improve Status badge. * Typos * Core code should not depend on Plugins for subnavigation * simplify code * Move subnavigation import to a php partial * Remove obsolete files.Add support for custom actions * Active navigation tab form deep associated model * fix active navigation tab first level * Fixed deep associations * Fix tab counter for all use cases * Fix active tabs everywhere. * fix depth calculation --- .../Model/Table/AttributeCollectorsTable.php | 25 ++++++++++-- app/src/Lib/Traits/TabTrait.php | 35 ++++++++++++++++- .../EnrollmentFlowSteps/fields-nav.inc | 31 --------------- app/templates/Petitions/fields-nav.inc | 39 +++++++++++++++++++ 4 files changed, 94 insertions(+), 36 deletions(-) delete mode 100644 app/templates/EnrollmentFlowSteps/fields-nav.inc diff --git a/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php b/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php index 2c7701b4c..23bd6e444 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php @@ -80,15 +80,32 @@ public function initialize(array $config): void { $this->setTabsConfig( [ // Ordered list of Tabs - 'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.AttributeCollectors', 'CoreEnroller.EnrollmentAttributes'], + 'tabs' => ['EnrollmentFlows', 'EnrollmentFlowSteps', 'Petitions'], // What actions will inlcude 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.AttributeCollectors' => ['edit'], - 'CoreEnroller.EnrollmentAttributes' => ['index'], + 'EnrollmentFlows' => ['edit', 'view'], + 'EnrollmentFlowSteps' => ['index'], + 'Petitions' => ['index'], + ], + // What model will have a counter-badge after the tab title + 'counter' => ['EnrollmentFlowSteps', 'Petitions'], + 'nested' => [ + // Ordered list of Tabs + 'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.AttributeCollectors', 'CoreEnroller.EnrollmentAttributes'], + // 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.AttributeCollectors' => ['edit'], + 'CoreEnroller.EnrollmentAttributes' => ['index'] + ], + // What model will have a counter-badge after the tab title + 'counter' => ['CoreEnroller.EnrollmentAttributes'], ] ] ); diff --git a/app/src/Lib/Traits/TabTrait.php b/app/src/Lib/Traits/TabTrait.php index 66f029f25..311bf3cef 100644 --- a/app/src/Lib/Traits/TabTrait.php +++ b/app/src/Lib/Traits/TabTrait.php @@ -1,6 +1,10 @@ >>>>>>> 9a427e22 (feature-cfm31-subnavigation (#217)):app/templates/element/subnavigation/inlineList.php * * Portions licensed to the University Corporation for Advanced Internet * Development, Inc. ("UCAID") under one or more contributor license agreements. @@ -25,8 +29,10 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ + declare(strict_types = 1); +<<<<<<<< HEAD:app/src/Lib/Traits/TabTrait.php namespace App\Lib\Traits; trait TabTrait @@ -68,4 +74,31 @@ public function setTabsConfig(array $tabsConfig): void $this->tabsConfig = $tabsConfig; } -} \ No newline at end of file +} +======== +$curAction = $this->request->getParam('action'); +$curController = $this->request->getParam('controller'); +$isNested = true; + +extract($vv_sub_nav_attributes, EXTR_PREFIX_ALL, 'vv_subnavigation'); + +$curId = $this->request->getQuery($vv_primary_link) + ?? $vv_obj->id + ?? end($vv_bc_title_links[0]['target']); +?> + + +
  • + element('subnavigation/tabTitle', compact('tab', 'curId', 'isNested')); + // Construct Target URL + $url = $this->Tab->constructLinkUrl($tab, $curId, $isNested); + // Calculate Tab Style Class(es) + $linkClass = $this->Tab->getLinkClass($tab, $isNested); + // Import element in the DOM + print $this->Html->link($title, $url, ['class' => $linkClass, 'escape' => false]); + ?> +
  • + +>>>>>>>> 9a427e22 (feature-cfm31-subnavigation (#217)):app/templates/element/subnavigation/inlineList.php diff --git a/app/templates/EnrollmentFlowSteps/fields-nav.inc b/app/templates/EnrollmentFlowSteps/fields-nav.inc deleted file mode 100644 index 7eebea083..000000000 --- a/app/templates/EnrollmentFlowSteps/fields-nav.inc +++ /dev/null @@ -1,31 +0,0 @@ - 'enrollment_flow', - 'active' => 'steps' -]; \ No newline at end of file diff --git a/app/templates/Petitions/fields-nav.inc b/app/templates/Petitions/fields-nav.inc index 1609fca83..2e475199b 100644 --- a/app/templates/Petitions/fields-nav.inc +++ b/app/templates/Petitions/fields-nav.inc @@ -1,6 +1,10 @@ >>>>>>> 9a427e22 (feature-cfm31-subnavigation (#217)):app/src/Lib/Traits/TabTrait.php * * Portions licensed to the University Corporation for Advanced Internet * Development, Inc. ("UCAID") under one or more contributor license agreements. @@ -25,6 +29,7 @@ * @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) */ +<<<<<<<< HEAD:app/templates/Petitions/fields-nav.inc $topLinks = [ [ 'icon' => 'resume', @@ -36,3 +41,37 @@ $topLinks = [ ] ] ]; +======== +declare(strict_types = 1); + +namespace App\Lib\Traits; + +trait TabTrait +{ + /** + * Tabs configuration + * + * @var array + */ + private array $tabsConfig = []; + + /** + * @return array + */ + public function getTabsConfig(): array + { + return $this->tabsConfig; + } + + /** + * @param array $tabsConfig + * + * @return void + */ + public function setTabsConfig(array $tabsConfig): void + { + $this->tabsConfig = $tabsConfig; + } + +} +>>>>>>>> 9a427e22 (feature-cfm31-subnavigation (#217)):app/src/Lib/Traits/TabTrait.php