diff --git a/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php b/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php
index dbe89f36a3..77f3748cee 100644
--- a/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php
+++ b/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php
@@ -1410,7 +1410,6 @@ class ObjectController extends BrickController
$sObjectClass = get_class($oObject);
$aObjectData = [
'id' => $oObject->GetKey(),
- 'object_class' => $sObjectClass,
'name' => $oObject->GetName(),
'attributes' => [],
];
@@ -1431,18 +1430,29 @@ class ObjectController extends BrickController
foreach ($aAttDefs as $oAttDef)
{
$aAttData = [
- 'att_code' => $oAttDef->GetCode(),
- 'attribute-type' => get_class($oAttDef),
+ 'object_class' => $sObjectClass,
+ 'object_id' => $oObject->GetKey(),
+ 'attribute_code' => $oAttDef->GetCode(),
+ 'attribute_type' => get_class($oAttDef),
];
// - Value raw
- if ($oAttDef::IsScalar()) {
- $aAttData['value-raw'] =utils::HtmlEntities( (string)$oObject->Get($oAttDef->GetCode()));
+ // For simple fields, we get the raw (stored) value as well
+ $bExcludeRawValue = false;
+ foreach (ApplicationHelper::GetAttDefClassesToExcludeFromMarkupMetadataRawValue() as $sAttDefClassToExclude)
+ {
+ if (is_a($oAttDef, $sAttDefClassToExclude, true))
+ {
+ $bExcludeRawValue = true;
+ break;
+ }
}
+ $aAttData['value_raw'] = ($bExcludeRawValue === false) ? $oObject->Get($oAttDef->GetCode()) : null;
+
if ($oAttDef->IsExternalKey())
{
- $aAttData['value'] = $oObject->GetAsHTML($oAttDef->GetCode().'_friendlyname');
+ $aAttData['value_html'] = $oObject->GetAsHTML($oAttDef->GetCode().'_friendlyname');
// Checking if user can access object's external key
if ($this->oSecurityHelper->IsActionAllowed(UR_ACTION_READ, $oAttDef->GetTargetClass()))
@@ -1474,14 +1484,14 @@ class ObjectController extends BrickController
{
$sUrl = $oAttDef->Get('default_image');
}
- $aAttData['value'] = '
';
+ $aAttData['value_html'] = '
';
}
elseif ($oAttDef instanceof AttributeEnum) {
- $aAttData['value'] = $oAttDef->GetAsPlainText($oObject->Get($oAttDef->GetCode()));
+ $aAttData['value_html'] = $oAttDef->GetAsPlainText($oObject->Get($oAttDef->GetCode()));
}
else
{
- $aAttData['value'] = $oAttDef->GetAsHTML($oObject->Get($oAttDef->GetCode()));
+ $aAttData['value_html'] = $oAttDef->GetAsHTML($oObject->Get($oAttDef->GetCode()));
if ($oAttDef instanceof AttributeFriendlyName)
{
diff --git a/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_search_regular.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_search_regular.html.twig
index 8d3b3cf13c..f428841584 100644
--- a/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_search_regular.html.twig
+++ b/datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_search_regular.html.twig
@@ -66,32 +66,35 @@
"title": oColumnProperties[sKey].title,
"defaultContent": "",
"type": "html",
- "data": "attributes."+sKey+".att_code",
- "render": function(data, type, row){
+ "data": "attributes."+sKey+".attribute_code",
+ "render": function(attribute_code, type, row){
var cellElem;
+ var metadataNames = ['object_class', 'object_id', 'attribute_code', 'attribute_type', 'value_raw'];
// Preparing the cell data
- if(row.attributes[data].url !== undefined)
+ if(row.attributes[attribute_code].url !== undefined)
{
cellElem = $('');
- cellElem.attr('target', '_blank').attr('href', row.attributes[data].url);
+ cellElem.attr('target', '_blank').attr('href', row.attributes[attribute_code].url);
}
else
{
cellElem = $('');
}
//Add markup
- cellElem.attr('data-object-id', row.id)
- cellElem.attr('data-object-class', row.object_class);
- cellElem.attr('data-attribute-type', row.attributes[data]['attribute-type']);
- cellElem.attr('data-attribute-code', row.attributes[data]['att_code']);
- console.warn('bob');
- if (row.attributes[data]['value-raw']!== undefined) {
- cellElem.attr('data-value-raw', row.attributes[data]['value-raw']);
+ for(var sPropName in row.attributes[attribute_code])
+ {
+ var propValue = row.attributes[attribute_code][sPropName];
+ if(sPropName === 'value_html')
+ {
+ cellElem.html(propValue);
+ }
+ else if(metadataNames.indexOf(sPropName) > -1)
+ {
+ cellElem.attr('data-'+sPropName.replace('_', '-'), propValue)
+ }
}
- cellElem.html( row.attributes[data].value );
-
return cellElem.prop('outerHTML');
},
});