Skip to content

Commit

Permalink
feature-cfm31-subnavigation (COmanage#217)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Ioannis authored and arlen committed Dec 19, 2024
1 parent 7d15da5 commit 530887e
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
]
]
);
Expand Down
35 changes: 34 additions & 1 deletion app/src/Lib/Traits/TabTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
/**
<<<<<<<< HEAD:app/src/Lib/Traits/TabTrait.php
* COmanage Registry Tab Trait
========
* COmanage Registry Tab Subnav Element
>>>>>>>> 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.
Expand All @@ -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
Expand Down Expand Up @@ -68,4 +74,31 @@ public function setTabsConfig(array $tabsConfig): void
$this->tabsConfig = $tabsConfig;
}

}
}
========
$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']);
?>

<?php foreach($vv_subnavigation_nested['tabs'] as $tab): ?>
<li class="list-inline-item">
<?php
// Construct Element Title
$title = $this->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 <a> element in the DOM
print $this->Html->link($title, $url, ['class' => $linkClass, 'escape' => false]);
?>
</li>
<?php endforeach; ?>
>>>>>>>> 9a427e22 (feature-cfm31-subnavigation (#217)):app/templates/element/subnavigation/inlineList.php
31 changes: 0 additions & 31 deletions app/templates/EnrollmentFlowSteps/fields-nav.inc

This file was deleted.

39 changes: 39 additions & 0 deletions app/templates/Petitions/fields-nav.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
/**
<<<<<<<< HEAD:app/templates/Petitions/fields-nav.inc
* COmanage Registry Petition Links
========
* COmanage Registry Tab Trait
>>>>>>>> 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.
Expand All @@ -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',
Expand All @@ -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

0 comments on commit 530887e

Please sign in to comment.