Skip to content

Commit

Permalink
custom person role subnavigation title
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Oct 3, 2024
1 parent c40380f commit 60c3dbf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
12 changes: 12 additions & 0 deletions app/resources/locales/en_US/operation.po
Original file line number Diff line number Diff line change
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}"

6 changes: 5 additions & 1 deletion app/src/Lib/Util/StringUtilities.php
Original file line number Diff line number Diff line change
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
7 changes: 4 additions & 3 deletions app/src/View/Helper/TabHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ public function constructLinkUrl(string $tab, string|int $curId, bool $isNested
[$plugin, $controller] = explode('.', $association);
break;
}
} else if (str_contains($tab, '@action.')) {
// Action has already been calculated above
$controller = $curController;
} else if (str_contains($tab, '@action')) {
// We have a plugin path
[$controller,] = explode('@', $modelName);
[, $action] = explode('.', $modelName);
} else if (str_contains($tab, '.')) {
// We have a plugin path
[$plugin, $controller] = explode('.', $modelName);
Expand Down
4 changes: 2 additions & 2 deletions app/templates/Standard/add-edit-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
// We might find ourselved in that situation since we calculate the title for the breadcrumbs and
// this simple description is not wrong. It is just not appropriate for the subnavigation title
$title = $vv_title;
$re = '/^(Add|Edit|View)\s[0-9]+/m';
$re = '/^(Add|Edit|View)\s([a-zA-Z]+?)\s[0-9]+/m';
$pregMatch = preg_match_all($re, $vv_title, $matches, PREG_SET_ORDER, 0);
if (
$hasSubnav
Expand All @@ -85,7 +85,7 @@
$vvObjTable = $this->Tab->getModelTableReference($fullModelsName);
$displayField = $vvObjTable->getDisplayField();
if($displayField !== 'id') {
$title = __d('operation', $vv_action . '.a', [$vv_obj->$displayField]);
$title = __d('operation', "$vv_action.$modelsName.a", [$vv_obj->$displayField]);
} else {
$title = __d('operation', $vv_action . '.a', [__d('controller', $modelsName, 1)]);
}
Expand Down

0 comments on commit 60c3dbf

Please sign in to comment.