Skip to content

Commit

Permalink
Cleanup to subnavigation and titling (CFM-31) (#229)
Browse files Browse the repository at this point in the history
* Cleanup to subnavigation and titling (CFM-31)

* Trivial cleanup (CFM-31)

* More trivial cleanup (CFM-31)

* Even more trivial cleanup (CFM-31)
  • Loading branch information
arlen authored Oct 2, 2024
1 parent f064512 commit d206890
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class EnrollmentAttributesTable extends Table {
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;
use \App\Lib\Traits\TabTrait;

/**
* Perform Cake Model initialization.
*
Expand Down Expand Up @@ -77,8 +77,8 @@ public function initialize(array $config): void {

$this->setPrimaryLink('CoreEnroller.attribute_collector_id');
$this->setRequiresCO(true);
$this->setRedirectGoal(action: 'add', goal: 'self');
$this->setRedirectGoal(action: 'edit', goal: 'self');
$this->setRedirectGoal(action: 'add', goal: 'index');
$this->setRedirectGoal(action: 'edit', goal: 'index');

$this->setAutoViewVars([
'addressRequiredFields' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ declare(strict_types = 1);

$this->Field->disableFormEditMode();

print __d('information', 'plugin.config.none');

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ $indexColumns = [
'label' => [
'type' => 'link',
'sortable' => true,
'class' => 'cm-modal-link nospin', // launch this in a modal
'dataAttrs' => [
['data-cm-modal-title', __d('operation', 'EnrollmentAttributes', 1)]
]
Expand Down Expand Up @@ -89,7 +88,7 @@ $action_args = array();
// and we will use the username instead.
$action_args['vv_attr_id'] = $vv_user['username'];
$action_args['vv_actions_type'] = 'mvea-add-menu';
$action_args['vv_actions_title'] = __d('operation', 'add');
$action_args['vv_actions_title'] = __d('operation', 'add.attribute');
$action_args['vv_actions_icon'] = 'add_circle';
$action_args['vv_actions_class'] = 'mvea-add-menu';
$actionOrderDefault = $this->Menu->getMenuOrder('Default');
Expand Down
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/information.po
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ msgstr "Active"
msgid "plugin.active.only"
msgstr "Active, Cannot Be Disabled"

msgid "plugin.config.none"
msgstr "This plugin requires no configuration."

msgid "plugin.inactive"
msgstr "Inactive"

Expand Down
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/operation.po
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ msgstr "Add"
msgid "add.a"
msgstr "Add a New {0}"

msgid "add.attribute"
msgstr "Add attribute"

msgid "add.member"
msgstr "Add member: "

Expand Down
3 changes: 2 additions & 1 deletion app/src/Model/Table/EnrollmentFlowStepsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +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\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

/**
* Perform Cake Model initialization.
*
Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/ExternalIdentityRolesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function initialize(array $config): void {
// render in index mode for the same use case/context
// XXX edit should go first.
'ExternalIdentities' => ['edit', 'view'],
'ExternalIdentityRoles' => ['index'],
'ExternalIdentityRoles' => ['edit', 'view', 'index'],
],
// What model will have a counter-badge after the tab title
'counter' => ['ExternalIdentityRoles'],
Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/PersonRolesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function initialize(array $config): void {
// render in index mode for the same use case/context
// XXX edit should go first.
'People' => ['edit', 'view'],
'PersonRoles' => ['edit', 'view', 'index'],
'PersonRoles' => ['edit','view','index'],
'ExternalIdentities' => ['index'],
],
// What model will have a counter-badge after the tab title
Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/PetitionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function initialize(array $config): void {
[
// Ordered list of Tabs
'tabs' => ['EnrollmentFlows', 'EnrollmentFlowSteps', 'Petitions'],
// What actions will inlcude the subnavigation header
// 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
Expand Down
11 changes: 5 additions & 6 deletions app/templates/EnrollmentFlowSteps/columns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ $indexColumns = [
],
'description' => [
'type' => 'link',
'sortable' => true
'sortable' => true,
'class' => 'cm-modal-link nospin row-link', // launch this in a modal
'dataAttrs' => [
['data-cm-modal-title', __d('controller', 'EnrollmentFlowSteps', 1)]
]
],
'actor_type' => [
'type' => 'enum',
Expand All @@ -57,8 +61,3 @@ $rowActions = [
'icon' => 'electrical_services'
]
];

$subnav = [
'name' => 'enrollment_flow',
'active' => 'steps'
];
9 changes: 5 additions & 4 deletions app/templates/Standard/add-edit-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@
}

// Subnavigation
$hasSubnav = false;
if(file_exists(ROOT . DS . 'templates' . DS . 'Standard/subnavigation.inc')) {
include(ROOT . DS . 'templates' . DS . 'Standard/subnavigation.inc');
$hasSubnav = $this->get('hasSupertitle');
}
?>

<div class="page-title-container">
<div class="page-title">
<?php if(empty($subnav)): ?>
<?php if(!$hasSubnav): ?>
<h1><?= $vv_title ?></h1>
<?php else: ?>
<h2><?= $vv_title ?></h2>
Expand Down Expand Up @@ -156,9 +158,8 @@
}
?>
</div>

<!-- If we have an iframe we alway render the flash messages -->
<?php if(empty($subnav) || $this->getLayout() === 'iframe'): ?>

<?php if(!$hasSubnav): ?>
<?php /* Flash Messages are placed below the main title when there's no subnavigation. */ ?>
<?= $this->element('flash', $flashArgs) ?>
<?php endif; ?>
Expand Down
7 changes: 4 additions & 3 deletions app/templates/Standard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@
}

// Subnavigation
$hasSubnav = false;
if(file_exists(ROOT . DS . 'templates' . DS . 'Standard/subnavigation.inc')) {
include(ROOT . DS . 'templates' . DS . 'Standard/subnavigation.inc');
$hasSubnav = $this->get('hasSupertitle');
}
?>

<div class="page-title-container">
<div class="page-title">
<?php if(empty($subnav)): ?>
<?php if(!$hasSubnav): ?>
<h1><?= $vv_title; ?></h1>
<?php else: ?>
<h2><?= $vv_title; ?></h2>
Expand Down Expand Up @@ -184,8 +186,7 @@
<?php endif; ?>
</div>

<?php if(empty($subnav)): ?>
<!-- Subnavigation -->
<?php if(!$hasSubnav): ?>
<?php /* Flash Messages are placed below the main title when there's no subnavigation. */ ?>
<?= $this->element('flash', $flashArgs); ?>
<?php endif; ?>
Expand Down
4 changes: 4 additions & 0 deletions app/templates/element/subnavigation/supertitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
default => __d('information','global.title.none')
};

// This allows us to know that we have subnavigation in the
// Standard views (index.php, add-edit-view.php).
$this->set('hasSupertitle', true);

?>

<h1><?= $supertitle ?></h1>

0 comments on commit d206890

Please sign in to comment.