Skip to content

feature-cfm31-subnavigation #217

Merged
merged 16 commits into from Sep 26, 2024
Expand Up @@ -44,7 +44,8 @@ class FileSourcesTable extends Table {
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

use \App\Lib\Traits\TabTrait;

// Cache of the field configuration
protected $fieldCfg = null;

Expand Down Expand Up @@ -78,6 +79,23 @@ public function initialize(array $config): void {
]
]);

// All the tabs share the same configuration in the ModelTable file
$this->setTabsConfig(
[
// Ordered list of Tabs
'tabs' => ['ExternalIdentitySources', 'FileConnector.FileSources', 'ExternalIdentitySources@action.search'],
// 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.
'ExternalIdentitySources' => ['edit', 'view', 'search'],
'FileConnector.FileSources' => ['edit'],
'ExternalIdentitySources@action.search' => [],
],
]
);

$this->setPermissions([
// Actions that operate over an entity (ie: require an $id)
'entity' => [
Expand Down

This file was deleted.

Expand Up @@ -42,6 +42,7 @@ class AttributeCollectorsTable extends Table {
use \App\Lib\Traits\CoLinkTrait;
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;

Expand Down Expand Up @@ -74,6 +75,40 @@ 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' => ['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.
'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'],
]
]
);

$this->setPermissions([
// Actions that operate over an entity (ie: require an $id)
'entity' => [
Expand Down
Expand Up @@ -46,6 +46,7 @@ class EnrollmentAttributesTable extends Table {
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;
use \App\Lib\Traits\TabTrait;

/**
* Perform Cake Model initialization.
Expand Down Expand Up @@ -157,6 +158,40 @@ public function initialize(array $config): void {
]
]);

// All the tabs share the same configuration in the ModelTable file
$this->setTabsConfig(
[
// Ordered list of Tabs
'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.
'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'],
]
]
);

$this->setPermissions([
// Actions that operate over an entity (ie: require an $id)
'entity' => [
Expand Down
Expand Up @@ -38,13 +38,14 @@ if($vv_action == 'dispatch') {
}
}

print $this->Field->control(
// We prefix the attribute ID with a string because Cake seems to sometimes have
// problems with field names that are purely integers (even if cast to strings)
fieldName: "field-".$attr->id,
labelText: $attr->label,
controlType: "string",
options: $options
);
print $this->element('form/listItem', [
'arguments' => [
// We prefix the attribute ID with a string because Cake seems to sometimes have
// problems with field names that are purely integers (even if cast to strings)
'fieldName' => 'field-' . $attr->id,
'fieldOptions' => $options,
'fieldLabel' => $attr->label
]
]);
}
}
13 changes: 0 additions & 13 deletions app/plugins/CoreEnroller/templates/EnrollmentAttributes/fields.inc
Expand Up @@ -533,19 +533,6 @@ if($vv_action == 'add' || $vv_action == 'edit') {
]
]]);

// print $this->Field->control(
// fieldName: 'default_value_validity_type',
// controlType: 'select',
// options: [
// 'options' => [
// 'on' => __d('core_enroller', 'enumeration.DefaultValueValidityType.on'),
// 'after' => __d('core_enroller', 'enumeration.DefaultValueValidityType.after')
// ],
//// 'empty' => false,
// 'onChange' => 'updateValidityGadgets()'
// ]
// );

// The default value is always stored in default_value, however for select based fields
// (such as cou_id or affiliation) the value is copied into default_value and the
// field specific attribute is used for display purposes only
Expand Down
13 changes: 8 additions & 5 deletions app/src/Controller/Component/BreadcrumbComponent.php
Expand Up @@ -191,7 +191,7 @@ public function injectPrimaryLink(object $link, bool $index=true, string $linkLa
// In the case we are dealing with non-standard actions we need to fallback to a standard one
// in order to get access to the contain array. We will use the permissions to decide which
// action to fall back to
if(!in_array($requestAction, [
if(!\in_array($requestAction, [
'index', 'view', 'delete', 'add', 'edit'
])) {
$permissionsArray = $this->getController()->RegistryAuth->calculatePermissionsForView($requestAction);
Expand Down Expand Up @@ -276,7 +276,7 @@ public function injectTitleLink(
$entity,
string $action='edit',
?string $label=null
) {
): void {
$displayField = $table->getDisplayField();

$this->injectTitleLinks[] = [
Expand All @@ -298,7 +298,8 @@ public function injectTitleLink(
* @param array $skipPaths Array of regular expressions describing paths to be skipped
*/

public function skipAll(array $skipPaths) {
public function skipAll(array $skipPaths): void
{
$this->skipAllPaths = $skipPaths;
}

Expand All @@ -311,7 +312,8 @@ public function skipAll(array $skipPaths) {
* @param array $skipPaths Array of regular expressions describing paths
*/

public function skipConfig(array $skipPaths) {
public function skipConfig(array $skipPaths): void
{
$this->skipConfigPaths = $skipPaths;
}

Expand All @@ -323,7 +325,8 @@ public function skipConfig(array $skipPaths) {
* @param array $skipPaths Array of regular expressions describing paths
*/

public function skipParents(array $skipPaths) {
public function skipParents(array $skipPaths): void
{
$this->skipParentPaths = $skipPaths;
}
}
@@ -1,6 +1,6 @@
<?php
/**
* COmanage Registry Tab Title With count Element
* COmanage Registry Tab Trait
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
Expand All @@ -23,17 +23,37 @@
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*
*
*/

if(empty($num)) {
$num = $this->Common->getModelTotalCount($model, $where);
}
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;
}

<span class='tab-count'>
<span class='tab-count-item'><?= $num ?></span>
</span>
<span class='tab-title'><?= $title ?></span>
}
11 changes: 6 additions & 5 deletions app/src/Lib/Util/StringUtilities.php
Expand Up @@ -220,12 +220,13 @@ public static function foreignKeyToClassName(string $s): string {

/**
* Localize a controller name, accounting for plugins.
*
* @since COmanage Registry v5.0.0
* @param string $controllerName Name of controller to localize
* @param string $pluginName Plugin name, if appropriate
* @param bool $plural Whether to use plural localization
*
* @param string $controllerName Name of controller to localize
* @param string|null $pluginName Plugin name, if appropriate
* @param bool $plural Whether to use plural localization
*
* @return string Localized text string
* @since COmanage Registry v5.0.0
*/

public static function localizeController(string $controllerName, ?string $pluginName, bool $plural=false): string {
Expand Down
38 changes: 37 additions & 1 deletion app/src/Model/Table/EnrollmentFlowStepsTable.php
Expand Up @@ -44,9 +44,10 @@ class EnrollmentFlowStepsTable extends Table {
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PluggableModelTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\TabTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

/**
* Perform Cake Model initialization.
*
Expand Down Expand Up @@ -110,6 +111,41 @@ public function initialize(array $config): void {
]
]
]);

$this->setTabsConfig(
[
// Ordered list of Tabs
'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.
'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', 'EnrollmentFlowSteps.Plugin', 'EnrollmentFlowSteps.Hierarchy'],
// 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'],
'EnrollmentFlowSteps.Plugin' => ['edit'],
// This means that we are looking at the plugins associated model
// EnrollmentFlowSteps -> plugin -> @plugin
'EnrollmentFlowSteps.Hierarchy' => ['index']
],
// What model will have a counter-badge after the tab title
'counter' => ['EnrollmentFlowSteps.Hierarchy'],
]
]
);
}

/**
Expand Down