Skip to content

Fix_missing_associations_tablist #238

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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
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