Skip to content

Commit

Permalink
Merge pull request #238 from Ioannis/Fix_missing_associations_tablist
Browse files Browse the repository at this point in the history
Fix_missing_associations_tablist
  • Loading branch information
Ioannis authored Oct 16, 2024
2 parents 59e1267 + d592cf4 commit 23ec40a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public function initialize(array $config): void {
'EnrollmentFlowSteps' => ['edit', 'view'],
'CoreEnroller.AttributeCollectors' => ['edit'],
'CoreEnroller.EnrollmentAttributes' => ['index'],
],
'skipTab' => ['CoreEnroller.AttributeCollectors']
]
]
);

Expand Down
11 changes: 4 additions & 7 deletions app/src/Model/Table/EnrollmentFlowStepsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ class EnrollmentFlowStepsTable extends Table {
use \App\Lib\Traits\AutoViewVarsTrait;
use \App\Lib\Traits\ChangelogBehaviorTrait;
use \App\Lib\Traits\CoLinkTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PluggableModelTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\TabTrait;
use \App\Lib\Traits\LayoutTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

/**
* Perform Cake Model initialization.
*
Expand Down Expand Up @@ -142,13 +142,10 @@ public function initialize(array $config): void {
'EnrollmentFlowSteps.Plugin' => ['edit'],
// This means that we are looking at the plugins associated model
// EnrollmentFlowSteps -> plugin -> @plugin
// XXX There might be plugins that have no hasMany associations. We will check
// for these use cases inside the element.
'EnrollmentFlowSteps.Hierarchy' => ['index']
],
// For whatever reason, we want to skip a tab from rendering. Here we do not render
// because the configuration has no fields.
// We do not do this dynamically since it is a very rare use case and the table
// has metadata fields. This means that we should filter them out.
'skipTab' => ['EnrollmentFlowSteps.Plugin']
]
]
);
Expand Down
2 changes: 0 additions & 2 deletions app/src/View/Helper/TabHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ public function getCurrentId(string $tabName = null, bool $isNested = false): in
return (int)$tid;
}



/**
* Check the belongsTo tree hierarchy
*
Expand Down
14 changes: 9 additions & 5 deletions app/templates/element/subnavigation/tabList.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,20 @@

<?php foreach($vv_subnavigation_tabs as $tab): ?>
<?php
if (isset($vv_sub_nav_attributes['skipTab'])
&& \in_array($tab, $vv_sub_nav_attributes['skipTab'], true)
) {
continue;
// calculate the id
$curId = $this->Tab->getCurrentId($tab, $isNested);
// Check if there are child models. If not continue
if (str_contains($tab, '.Hierarchy')) {
$modelName = $this->Tab->retrievePluginName($tab, (int)$curId);
[$plugin, ] = explode('.', $modelName);
if($this->Tab->getHasManyAssociationModels($modelName)->current() === null) {
continue;
}
}
?>
<!-- if a tab has no fields do not render skip -->
<li class="nav-item">
<?php
$curId = $this->Tab->getCurrentId($tab, $isNested);
// Calculate Tab Title
$title = $this->element('subnavigation/tabTitle', compact('tab', 'curId', 'isNested'));
// Construct Target URL
Expand Down

0 comments on commit 23ec40a

Please sign in to comment.