diff --git a/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php b/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php index 38285c7c..0f423e5e 100644 --- a/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php +++ b/app/plugins/CoreEnroller/src/Controller/EnrollmentAttributesController.php @@ -61,13 +61,28 @@ public function beforeRender(\Cake\Event\EventInterface $event) { $ret = parent::beforeRender($event); + $attributes = $this->viewBuilder()->getVar('attributes'); + // Override the auto-generated title switch($this->request->getParam('action')) { case 'add': - $this->set('vv_title', __d('operation', 'add.a', [__d('core_enroller', 'controller.EnrollmentAttributes', [1])])); + $this->set( + 'vv_title', + __d('operation', 'add.a-1', [ + __d('core_enroller', 'controller.EnrollmentAttributes', [1]), + $attributes[$this->request->getQuery('attribute_type')] + ]) + ); break; case 'edit': - $this->set('vv_title', __d('operation', 'edit.a', [__d('core_enroller', 'controller.EnrollmentAttributes', [1])])); + $vv_obj = $this->viewBuilder()->getVar('vv_obj'); + $this->set( + 'vv_title', + __d('operation', 'edit.a-1', [ + __d('core_enroller', 'controller.EnrollmentAttributes', [1]), + $attributes[ $vv_obj['attribute'] ] + ]) + ); break; case 'index': $this->set('vv_title', __d('core_enroller', 'controller.EnrollmentAttributes', [99])); diff --git a/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php b/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php index 2c1699dd..e7f74a3e 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/AttributeCollectorsTable.php @@ -40,6 +40,7 @@ class AttributeCollectorsTable extends Table { use \App\Lib\Traits\AutoViewVarsTrait; use \App\Lib\Traits\CoLinkTrait; + use \App\Lib\Traits\LayoutTrait; use \App\Lib\Traits\PermissionsTrait; use \App\Lib\Traits\PrimaryLinkTrait; use \App\Lib\Traits\TabTrait; @@ -79,33 +80,17 @@ public function initialize(array $config): void { $this->setTabsConfig( [ // Ordered list of Tabs - 'tabs' => ['EnrollmentFlows', 'EnrollmentFlowSteps', 'Petitions'], + 'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.AttributeCollectors', 'CoreEnroller.EnrollmentAttributes'], // 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'], + 'EnrollmentFlowSteps' => ['edit', 'view'], + 'CoreEnroller.AttributeCollectors' => ['edit'], + 'CoreEnroller.EnrollmentAttributes' => ['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'], - ] + 'skipTab' => ['CoreEnroller.AttributeCollectors'] ] ); diff --git a/app/plugins/CoreEnroller/src/Model/Table/EnrollmentAttributesTable.php b/app/plugins/CoreEnroller/src/Model/Table/EnrollmentAttributesTable.php index 82dbfd24..d9ffeea2 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/EnrollmentAttributesTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/EnrollmentAttributesTable.php @@ -41,12 +41,12 @@ class EnrollmentAttributesTable extends Table { use \App\Lib\Traits\AutoViewVarsTrait; use \App\Lib\Traits\CoLinkTrait; + use \App\Lib\Traits\LayoutTrait; 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; - use \App\Lib\Traits\TabTrait; - use \App\Lib\Traits\LayoutTrait; /** * Perform Cake Model initialization. @@ -158,37 +158,27 @@ public function initialize(array $config): void { ] ]); + $this->setLayout([ 'index' => 'iframe', + 'add' => 'iframe', + 'edit' => 'iframe', + 'view' => 'iframe', + ]); + // All the tabs share the same configuration in the ModelTable file $this->setTabsConfig( [ // Ordered list of Tabs - 'tabs' => ['EnrollmentFlows', 'EnrollmentFlowSteps', 'Petitions'], + 'tabs' => ['EnrollmentFlowSteps', 'CoreEnroller.AttributeCollectors', 'CoreEnroller.EnrollmentAttributes'], // 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'], + 'EnrollmentFlowSteps' => ['edit', 'view'], + 'CoreEnroller.AttributeCollectors' => ['edit'], + 'CoreEnroller.EnrollmentAttributes' => ['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'], - ] + 'skipTab' => ['CoreEnroller.AttributeCollectors'] ] ); diff --git a/app/plugins/CoreEnroller/templates/EnrollmentAttributes/columns.inc b/app/plugins/CoreEnroller/templates/EnrollmentAttributes/columns.inc index 9fdc0d76..8281f4cb 100644 --- a/app/plugins/CoreEnroller/templates/EnrollmentAttributes/columns.inc +++ b/app/plugins/CoreEnroller/templates/EnrollmentAttributes/columns.inc @@ -33,7 +33,7 @@ $indexColumns = [ 'label' => [ 'type' => 'link', 'sortable' => true, - 'class' => 'cm-modal-link nospin', // launch this in a modal +// 'class' => 'cm-modal-link nospin', // launch this in a modal 'dataAttrs' => [ ['data-cm-modal-title', __d('operation', 'EnrollmentAttributes', 1)] ] @@ -94,8 +94,13 @@ $action_args['vv_actions_icon'] = 'add_circle'; $action_args['vv_actions_class'] = 'mvea-add-menu'; $actionOrderDefault = $this->Menu->getMenuOrder('Default'); foreach ($attributes as $attr => $hr_name) { + $title = __d('operation', 'add.a-1', [ + __d('core_enroller', 'controller.EnrollmentAttributes', [1]), + $hr_name + ]); $actionLabel = $hr_name; - $actionClass = 'cm-modal-link nospin'; + // XXX This is already inside a modal. We just need the layout to be correct +// $actionClass = 'cm-modal-link nospin'; $actionOrder = $actionOrderDefault++; $actionIcon = $attributeToIcons[$attr] ?? $this->Menu->getMenuIcon('Default'); $dataAttrs = ['data-cm-modal-title', __d('file-connector', 'EnrollmentAttributes', 1)]; @@ -111,7 +116,7 @@ foreach ($attributes as $attr => $hr_name) { 'icon' => $actionIcon, 'iconClass' => '', 'url' => $actionUrl, - 'class' => $actionClass, + 'class' => $actionClass ?? '', 'label' => $actionLabel, 'dataAttrs' => [] ]; diff --git a/app/resources/locales/en_US/operation.po b/app/resources/locales/en_US/operation.po index 2101f4d2..aeb7168d 100644 --- a/app/resources/locales/en_US/operation.po +++ b/app/resources/locales/en_US/operation.po @@ -36,6 +36,9 @@ msgstr "Add" msgid "add.a" msgstr "Add a New {0}" +msgid "add.a-1" +msgstr "Add a New {0} `{1}`" + msgid "add.attribute" msgstr "Add attribute" @@ -135,6 +138,9 @@ msgstr "Edit" msgid "edit.a" msgstr "Edit {0}" +msgid "edit.a-1" +msgstr "Edit {0} `{1}`" + msgid "edit.PersonRoles.a" msgstr "Edit Role {0}" diff --git a/app/src/Lib/Traits/LayoutTrait.php b/app/src/Lib/Traits/LayoutTrait.php index a24143c7..b178b507 100644 --- a/app/src/Lib/Traits/LayoutTrait.php +++ b/app/src/Lib/Traits/LayoutTrait.php @@ -31,13 +31,26 @@ trait LayoutTrait { + /** + * Layout configuration + * + * @var array + * @since COmanage Registry v5.0.0 + */ + private array $layout = []; + /** * Provide the default layout * * @since COmanage Registry v5.0.0 * @return string Type of redirect */ - public function getLayout(string $action = ''): string { + public function getLayout(string $action = ''): string + { + if(!empty($this->layout)) { + return $this->layout[$action]; + } + return match($action) { 'add', 'view', @@ -45,4 +58,17 @@ public function getLayout(string $action = ''): string { default => 'default' }; } + + /** + * Set the layout variable + * + * @param array $layout + * + * @return void + * @since COmanage Registry v5.0.0 + */ + public function setLayout(array $layout): void + { + $this->layout = $layout; + } } \ No newline at end of file diff --git a/app/src/Lib/Traits/TabTrait.php b/app/src/Lib/Traits/TabTrait.php index 331224cd..66f029f2 100644 --- a/app/src/Lib/Traits/TabTrait.php +++ b/app/src/Lib/Traits/TabTrait.php @@ -40,11 +40,20 @@ trait TabTrait private array $tabsConfig = []; /** - * @return array + * Get the configuration for tabs based on the specified action. + * + * @param string $action The action for which the tab configuration is requested. + * + * @return array The tab configuration for the specified action, or the entire tab configuration + * if the action is not specified or invalid. * @since COmanage Registry v5.0.0 */ - public function getTabsConfig(): array + public function getTabsConfig(string $action): array { + if(!empty($action) && !empty($this->tabsConfig[$action])) { + return $this->tabsConfig[$action]; + } + return $this->tabsConfig; } diff --git a/app/src/Model/Table/EnrollmentFlowStepsTable.php b/app/src/Model/Table/EnrollmentFlowStepsTable.php index fd3bd94f..f48c612b 100644 --- a/app/src/Model/Table/EnrollmentFlowStepsTable.php +++ b/app/src/Model/Table/EnrollmentFlowStepsTable.php @@ -45,6 +45,7 @@ class EnrollmentFlowStepsTable extends Table { 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; @@ -114,23 +115,25 @@ 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'], + 'index' => [ + // 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'] ], - // What model will have a counter-badge after the tab title - 'counter' => ['EnrollmentFlowSteps', 'Petitions'], - 'nested' => [ + 'edit' => [ // Ordered list of Tabs 'tabs' => ['EnrollmentFlowSteps', 'EnrollmentFlowSteps.Plugin', 'EnrollmentFlowSteps.Hierarchy'], - // What actions will include the subnavigation header + // 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 @@ -141,8 +144,11 @@ public function initialize(array $config): void { // EnrollmentFlowSteps -> plugin -> @plugin 'EnrollmentFlowSteps.Hierarchy' => ['index'] ], - // What model will have a counter-badge after the tab title - 'counter' => ['EnrollmentFlowSteps.Hierarchy'], + // 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'] ] ] ); diff --git a/app/src/Model/Table/NamesTable.php b/app/src/Model/Table/NamesTable.php index 8b960aab..df19131c 100644 --- a/app/src/Model/Table/NamesTable.php +++ b/app/src/Model/Table/NamesTable.php @@ -65,18 +65,6 @@ class NamesTable extends Table { 'preferred' ] ]; - - /** - * Provide the default layout - * - * @since COmanage Registry v5.0.0 - * @return string Type of redirect - */ - public function getLayout(string $action = ''): string { - return match($action) { - default => 'iframe' - }; - } /** * Perform Cake Model initialization. diff --git a/app/templates/EnrollmentFlowSteps/columns.inc b/app/templates/EnrollmentFlowSteps/columns.inc index 6786d79d..133c20ea 100644 --- a/app/templates/EnrollmentFlowSteps/columns.inc +++ b/app/templates/EnrollmentFlowSteps/columns.inc @@ -33,6 +33,10 @@ $indexColumns = [ 'description' => [ 'type' => 'link', 'sortable' => true, + 'class' => 'cm-modal-link nospin', // launch this in a modal + 'dataAttrs' => [ + ['data-cm-modal-title', __d('controller', 'EnrollmentFlowSteps', 1)] + ] ], 'actor_type' => [ 'type' => 'enum', diff --git a/app/templates/Standard/subnavigation.inc b/app/templates/Standard/subnavigation.inc index 13d3460e..9192aff9 100644 --- a/app/templates/Standard/subnavigation.inc +++ b/app/templates/Standard/subnavigation.inc @@ -32,7 +32,7 @@ declare(strict_types = 1); $fullModelsName = !empty($this->getPlugin()) ? $this->getPlugin() . '.' . $modelsName : $modelsName; $modelsTable = $this->Tab->getModelTableReference($fullModelsName); if(method_exists($modelsTable, 'getTabsConfig')) { - $tabsConfiguration = $modelsTable->getTabsConfig(); + $tabsConfiguration = $modelsTable->getTabsConfig($vv_action); $subnav = [ 'flashArgs' => $flashArgs ?? [], ...$tabsConfiguration diff --git a/app/templates/element/subnavigation/tabList.php b/app/templates/element/subnavigation/tabList.php index f5baabb3..03342c97 100644 --- a/app/templates/element/subnavigation/tabList.php +++ b/app/templates/element/subnavigation/tabList.php @@ -36,6 +36,14 @@ ?> + +