Skip to content

Subnavigation fixes #230

Merged
merged 1 commit into from Oct 3, 2024
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 @@ -30,11 +30,34 @@
namespace FileConnector\Controller;

use App\Controller\StandardPluginController;
use Cake\Event\EventInterface;
use Cake\Http\Response;

class FileSourcesController extends StandardPluginController {
public $paginate = [
'order' => [
'FileSources.id' => 'asc'
]
];

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
*/

public function beforeRender(EventInterface $event) {
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->FileSources->ExternalIdentitySources->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->FileSources->ExternalIdentitySources->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->FileSources->ExternalIdentitySources->getPrimaryKey());
}

return parent::beforeRender($event);
}
}
Expand Up @@ -31,6 +31,8 @@

use App\Controller\StandardEnrollerController;
use App\Lib\Enum\PetitionStatusEnum;
use Cake\Event\EventInterface;
use Cake\Http\Response;

class AttributeCollectorsController extends StandardEnrollerController {
public $paginate = [
Expand All @@ -39,6 +41,27 @@ class AttributeCollectorsController extends StandardEnrollerController {
]
];

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
*/

public function beforeRender(EventInterface $event) {
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->AttributeCollectors->EnrollmentFlowSteps->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->AttributeCollectors->EnrollmentFlowSteps->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->AttributeCollectors->EnrollmentFlowSteps->getPrimaryKey());
}

return parent::beforeRender($event);
}

/**
* Dispatch an Enrollment Flow Step.
*
Expand Down
Expand Up @@ -51,6 +51,14 @@ class EnrollmentAttributesController extends StandardEnrollerController {
public function beforeRender(\Cake\Event\EventInterface $event) {
$this->set('vv_supported_attributes', $this->EnrollmentAttributes->supportedAttributes());

$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->EnrollmentAttributes->AttributeCollectors->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->EnrollmentAttributes->AttributeCollectors->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->EnrollmentAttributes->AttributeCollectors->getPrimaryKey());
}

$ret = parent::beforeRender($event);

// Override the auto-generated title
Expand Down
Expand Up @@ -40,7 +40,6 @@
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
Expand Up @@ -41,13 +41,13 @@
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\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;
use \App\Lib\Traits\TabTrait;

use \App\Lib\Traits\LayoutTrait;

/**
* Perform Cake Model initialization.
*
Expand Down
Expand Up @@ -33,6 +33,7 @@ $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
12 changes: 12 additions & 0 deletions app/resources/locales/en_US/operation.po
Expand Up @@ -135,6 +135,12 @@ msgstr "Edit"
msgid "edit.a"
msgstr "Edit {0}"

msgid "edit.PersonRoles.a"
msgstr "Edit Role {0}"

msgid "edit.ExternalIdentityRoles.a"
msgstr "Edit Role {0}"

msgid "EmailAddresses.verify.force"
msgstr "Force Verify"

Expand Down Expand Up @@ -267,3 +273,9 @@ msgstr "View"
msgid "view.a"
msgstr "View {0}"

msgid "view.PersonRoles.a"
msgstr "View Role {0}"

msgid "view.ExternalIdentityRoles.a"
msgstr "View Role {0}"

25 changes: 25 additions & 0 deletions app/src/Controller/EnrollmentFlowStepsController.php
Expand Up @@ -30,6 +30,8 @@
namespace App\Controller;

// XXX not doing anything with Log yet
use Cake\Event\EventInterface;
use Cake\Http\Response;
use Cake\Log\Log;

class EnrollmentFlowStepsController extends StandardPluggableController {
Expand All @@ -38,4 +40,27 @@ class EnrollmentFlowStepsController extends StandardPluggableController {
'EnrollmentFlowSteps.ordr' => 'asc'
]
];

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
*/

public function beforeRender(EventInterface $event) {
// Pull the Person name for breadcrumb rendering

$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->EnrollmentFlowSteps->EnrollmentFlows->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->EnrollmentFlowSteps->EnrollmentFlows->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->EnrollmentFlowSteps->EnrollmentFlows->getPrimaryKey());
}

return parent::beforeRender($event);
}
}
28 changes: 25 additions & 3 deletions app/src/Controller/ExternalIdentitiesController.php
Expand Up @@ -29,9 +29,8 @@

namespace App\Controller;

// XXX not doing anything with Log yet
use Cake\Log\Log;
use Cake\ORM\TableRegistry;
use Cake\Event\EventInterface;
use Cake\Http\Response;

// Use extend MVEAController for breadcrumb rendering. ExternalIdentities is
// sort of an MVEA, so maybe it makes sense to treat it as such.
Expand All @@ -45,4 +44,27 @@ class ExternalIdentitiesController extends MVEAController {
'Names.family'
]
];

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
*/

public function beforeRender(EventInterface $event) {
// Pull the Person name for breadcrumb rendering

$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->ExternalIdentities->People->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->ExternalIdentities->People->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->ExternalIdentities->People->getPrimaryKey());
}

return parent::beforeRender($event);
}
}
1 change: 1 addition & 0 deletions app/src/Controller/GroupMembersController.php
Expand Up @@ -58,6 +58,7 @@ public function beforeRender(EventInterface $event) {
if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->GroupMembers->Groups->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->GroupMembers->Groups->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->GroupMembers->Groups->getPrimaryKey());
}

return parent::beforeRender($event);
Expand Down
1 change: 1 addition & 0 deletions app/src/Controller/GroupNestingsController.php
Expand Up @@ -54,6 +54,7 @@ public function beforeRender(\Cake\Event\EventInterface $event) {
if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->GroupNestings->Groups->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->GroupNestings->Groups->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->GroupNestings->Groups->getPrimaryKey());
}

// We need to calculate the available set of groups for nesting. We do this
Expand Down
1 change: 1 addition & 0 deletions app/src/Controller/JobHistoryRecordsController.php
Expand Up @@ -55,6 +55,7 @@ public function beforeRender(\Cake\Event\EventInterface $event) {
if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->JobHistoryRecords->Jobs->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->JobHistoryRecords->Jobs->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->JobHistoryRecords->Jobs->getPrimaryKey());
}

return parent::beforeRender($event);
Expand Down
25 changes: 24 additions & 1 deletion app/src/Controller/PetitionsController.php
Expand Up @@ -30,12 +30,14 @@
namespace App\Controller;

// XXX not doing anything with Log yet
use Cake\Event\EventInterface;
use Cake\Http\Response;
use Cake\Log\Log;
use Cake\ORM\TableRegistry;
use Cake\Utility\Inflector;
use \App\Lib\Util\StringUtilities;
use \App\Lib\Enum\EnrollmentActorEnum;
use \App\Lib\Enum\SuspendableStatusEnum;
use \App\Lib\Util\StringUtilities;

class PetitionsController extends StandardController {
use \App\Lib\Traits\EnrollmentControllerTrait;
Expand All @@ -49,6 +51,27 @@ class PetitionsController extends StandardController {
// Cached copy of the next step information
private $nextStep = null;

/**
* Callback run prior to the request render.
*
* @param EventInterface $event Cake Event
*
* @return Response|void
* @since COmanage Registry v5.0.0
*/

public function beforeRender(EventInterface $event) {
$link = $this->getPrimaryLink(true);

if(!empty($link->value)) {
$this->set('vv_bc_parent_obj', $this->Petitions->EnrollmentFlows->get($link->value));
$this->set('vv_bc_parent_displayfield', $this->Petitions->EnrollmentFlows->getDisplayField());
$this->set('vv_bc_parent_primarykey', $this->Petitions->EnrollmentFlows->getPrimaryKey());
}

return parent::beforeRender($event);
}

/**
* Calculate authorization for the current request.
*
Expand Down
1 change: 1 addition & 0 deletions app/src/Controller/StandardPluginController.php
Expand Up @@ -96,6 +96,7 @@ public function beforeRender(\Cake\Event\EventInterface $event) {

$this->set('vv_bc_parent_obj', $parentObj);
$this->set('vv_bc_parent_displayfield', $parentDisplayField);
$this->set('vv_bc_parent_primarykey', $parentTable->getPrimaryKey());

// Override the title set in StandardController. Since that was set in edit()
// which is called before the rendering hooks, this title will take precedence.
Expand Down
6 changes: 5 additions & 1 deletion app/src/Lib/Util/StringUtilities.php
Expand Up @@ -162,6 +162,7 @@ public static function entityAndActionToTitle($entity,

$linkTable = TableRegistry::getTableLocator()->get($modelPath);
$msgId = "{$action}.a";
$msgIdOverride = "{$action}.{$modelsName}.a";

if(Inflector::singularize(self::entityToClassName($entity)) !== Inflector::singularize($modelsName)) {
$linkTable = TableRegistry::getTableLocator()->get(self::entityToClassName($entity));
Expand All @@ -188,7 +189,10 @@ public static function entityAndActionToTitle($entity,
&& method_exists($linkTable, 'generateDisplayField')) {
// We don't use a trait for this since each table will implement different logic

$title = __d($domain, $msgId, $linkTable->generateDisplayField($entity));
$title = __d($domain, $msgIdOverride, $linkTable->generateDisplayField($entity));
if ($msgIdOverride === $title) {
$title = __d($domain, $msgId, $linkTable->generateDisplayField($entity));
}
$supertitle = $linkTable->generateDisplayField($entity);
// Pass the display field also into subtitle for dealing with External IDs
$subtitle = $linkTable->generateDisplayField($entity);
Expand Down
1 change: 0 additions & 1 deletion app/src/Model/Table/EnrollmentFlowStepsTable.php
Expand Up @@ -41,7 +41,6 @@ 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;
Expand Down
6 changes: 3 additions & 3 deletions app/src/Model/Table/ExternalIdentityRolesTable.php
Expand Up @@ -46,10 +46,10 @@ class ExternalIdentityRolesTable extends Table {
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\QueryModificationTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;
use \App\Lib\Traits\SearchFilterTrait;
use \App\Lib\Traits\TabTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

/**
* Perform Cake Model initialization.
Expand Down Expand Up @@ -91,7 +91,7 @@ public function initialize(array $config): void {
->setDependent(true)
->setCascadeCallbacks(true);

$this->setDisplayField('id');
$this->setDisplayField('title');

$this->setPrimaryLink('external_identity_id');
$this->setRequiresCO(true);
Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/PersonRolesTable.php
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