From 60c3dbf3071da18f45228ddb421d04ce2231a1c7 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Thu, 3 Oct 2024 21:23:06 +0300 Subject: [PATCH] custom person role subnavigation title --- app/resources/locales/en_US/operation.po | 12 ++++++++++++ app/src/Lib/Util/StringUtilities.php | 6 +++++- app/src/View/Helper/TabHelper.php | 7 ++++--- app/templates/Standard/add-edit-view.php | 4 ++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/resources/locales/en_US/operation.po b/app/resources/locales/en_US/operation.po index c30bec0e2..2101f4d29 100644 --- a/app/resources/locales/en_US/operation.po +++ b/app/resources/locales/en_US/operation.po @@ -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" @@ -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}" + diff --git a/app/src/Lib/Util/StringUtilities.php b/app/src/Lib/Util/StringUtilities.php index cad2457de..d1d5e644c 100644 --- a/app/src/Lib/Util/StringUtilities.php +++ b/app/src/Lib/Util/StringUtilities.php @@ -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)); @@ -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); diff --git a/app/src/View/Helper/TabHelper.php b/app/src/View/Helper/TabHelper.php index 7892e9836..23b6adc12 100644 --- a/app/src/View/Helper/TabHelper.php +++ b/app/src/View/Helper/TabHelper.php @@ -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); diff --git a/app/templates/Standard/add-edit-view.php b/app/templates/Standard/add-edit-view.php index 2246eb17b..0d6d6fbc2 100644 --- a/app/templates/Standard/add-edit-view.php +++ b/app/templates/Standard/add-edit-view.php @@ -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 @@ -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)]); }