N°6327 - Enum, Date, FinalClass in Complementary Name not labelized#783
N°6327 - Enum, Date, FinalClass in Complementary Name not labelized#783accognet wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #6327 by fixing how Enum, Date, and FinalClass attributes are displayed in complementary names. The change switches from using Get() to GetAsCSV() to obtain user-friendly, localized values for attributes used in complementary names.
Changes:
- Modified complementary name generation to use
GetAsCSV()instead ofGet()for proper localization of Enum, Date, and FinalClass attributes - Updated
complementary_name_attcodefrom['finalclass', 'complement']to['finalclass', 'target_class']across all Trigger classes - Enhanced dictionary entries for
Class:Trigger/ComplementaryNameto include descriptive labels like "class restriction:" in multiple languages
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| sources/Service/Base/ObjectRepository.php | Changed to use GetAsCSV() for complementary name attributes to get formatted, user-friendly values |
| core/valuesetdef.class.inc.php | Updated autocomplete value loading to use GetAsCSV() for proper attribute formatting |
| application/ui.extkeywidget.class.inc.php | Modified external key widget to use GetAsCSV() for displaying additional fields with proper formatting |
| core/trigger.class.inc.php | Updated complementary_name_attcode to use 'target_class' directly instead of 'complement' for all Trigger subclasses |
| datamodels/2.x/itop-attachments/src/Trigger/*.php | Updated attachment trigger classes to use 'target_class' in complementary_name_attcode |
| dictionaries/*.dictionary.itop.core.php | Updated ComplementaryName format strings to include descriptive text for class restriction in multiple languages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "key_type" => "autoincrement", | ||
| "name_attcode" => "description", | ||
| "complementary_name_attcode" => ['finalclass', 'complement'], | ||
| "complementary_name_attcode" => ['finalclass', 'target_class'], |
There was a problem hiding this comment.
The 'target_class' attribute (AttributeClass type) doesn't localize class names in its GetAsCSV() method. Unlike AttributeEnum, AttributeDateTime, and AttributeFinalClass which properly localize/format values in GetAsCSV(), AttributeClass only inherits the base AttributeString implementation which doesn't localize. This means when GetAsCSV() is called on 'target_class' in ObjectRepository::ComputeOthersData() and other locations, users will see raw class names like "UserRequest" instead of localized names like "User Request" or their translated equivalents. AttributeClass should override GetAsCSV() similar to how AttributeFinalClass does (see sources/Core/AttributeDefinition/AttributeFinalClass.php:150) to call MetaModel::GetName() when $bLocalize is true.
| "complementary_name_attcode" => ['finalclass', 'target_class'], | |
| "complementary_name_attcode" => ['finalclass'], |
| foreach ($aAdditionalField as $sAdditionalField) { | ||
| array_push($aArguments, $oObj->Get($sAdditionalField)); | ||
| //getAsCSV to have user friendly value in text format | ||
| array_push($aArguments, $oObj->GetAsCSV($sAdditionalField, ' ', '')); |
There was a problem hiding this comment.
Why use GetAsCSV here ?? It as nothing to do with a CSV. Do we really want double quotes around the value if there are spaces in it ??
There was a problem hiding this comment.
GetAsCSV returns the value in the correct format, which is why I'm using it here even though it's not a CSV.
3a3519c to
c5a6b34
Compare
Co-authored-by: Thomas Casteleyn <thomas.casteleyn@super-visions.com>
10a08b1 to
81e9ef8
Compare
internal