N°7146 - Fix style not applied in list in the end-users portal in iTop 3.0+

This commit is contained in:
Anne-Cath
2024-04-15 15:09:42 +02:00
committed by Molkobain
parent 1bb3fe5e0a
commit 974eafbf4a
2 changed files with 35 additions and 22 deletions

View File

@@ -1410,7 +1410,6 @@ class ObjectController extends BrickController
$sObjectClass = get_class($oObject); $sObjectClass = get_class($oObject);
$aObjectData = [ $aObjectData = [
'id' => $oObject->GetKey(), 'id' => $oObject->GetKey(),
'object_class' => $sObjectClass,
'name' => $oObject->GetName(), 'name' => $oObject->GetName(),
'attributes' => [], 'attributes' => [],
]; ];
@@ -1431,18 +1430,29 @@ class ObjectController extends BrickController
foreach ($aAttDefs as $oAttDef) foreach ($aAttDefs as $oAttDef)
{ {
$aAttData = [ $aAttData = [
'att_code' => $oAttDef->GetCode(), 'object_class' => $sObjectClass,
'attribute-type' => get_class($oAttDef), 'object_id' => $oObject->GetKey(),
'attribute_code' => $oAttDef->GetCode(),
'attribute_type' => get_class($oAttDef),
]; ];
// - Value raw // - Value raw
if ($oAttDef::IsScalar()) { // For simple fields, we get the raw (stored) value as well
$aAttData['value-raw'] =utils::HtmlEntities( (string)$oObject->Get($oAttDef->GetCode())); $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()) 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 // Checking if user can access object's external key
if ($this->oSecurityHelper->IsActionAllowed(UR_ACTION_READ, $oAttDef->GetTargetClass())) if ($this->oSecurityHelper->IsActionAllowed(UR_ACTION_READ, $oAttDef->GetTargetClass()))
@@ -1474,14 +1484,14 @@ class ObjectController extends BrickController
{ {
$sUrl = $oAttDef->Get('default_image'); $sUrl = $oAttDef->Get('default_image');
} }
$aAttData['value'] = '<img src="'.$sUrl.'" />'; $aAttData['value_html'] = '<img src="'.$sUrl.'" />';
} }
elseif ($oAttDef instanceof AttributeEnum) { elseif ($oAttDef instanceof AttributeEnum) {
$aAttData['value'] = $oAttDef->GetAsPlainText($oObject->Get($oAttDef->GetCode())); $aAttData['value_html'] = $oAttDef->GetAsPlainText($oObject->Get($oAttDef->GetCode()));
} }
else else
{ {
$aAttData['value'] = $oAttDef->GetAsHTML($oObject->Get($oAttDef->GetCode())); $aAttData['value_html'] = $oAttDef->GetAsHTML($oObject->Get($oAttDef->GetCode()));
if ($oAttDef instanceof AttributeFriendlyName) if ($oAttDef instanceof AttributeFriendlyName)
{ {

View File

@@ -66,31 +66,34 @@
"title": oColumnProperties[sKey].title, "title": oColumnProperties[sKey].title,
"defaultContent": "", "defaultContent": "",
"type": "html", "type": "html",
"data": "attributes."+sKey+".att_code", "data": "attributes."+sKey+".attribute_code",
"render": function(data, type, row){ "render": function(attribute_code, type, row){
var cellElem; var cellElem;
var metadataNames = ['object_class', 'object_id', 'attribute_code', 'attribute_type', 'value_raw'];
// Preparing the cell data // Preparing the cell data
if(row.attributes[data].url !== undefined) if(row.attributes[attribute_code].url !== undefined)
{ {
cellElem = $('<a></a>'); cellElem = $('<a></a>');
cellElem.attr('target', '_blank').attr('href', row.attributes[data].url); cellElem.attr('target', '_blank').attr('href', row.attributes[attribute_code].url);
} }
else else
{ {
cellElem = $('<span></span>'); cellElem = $('<span></span>');
} }
//Add markup //Add markup
cellElem.attr('data-object-id', row.id) for(var sPropName in row.attributes[attribute_code])
cellElem.attr('data-object-class', row.object_class); {
cellElem.attr('data-attribute-type', row.attributes[data]['attribute-type']); var propValue = row.attributes[attribute_code][sPropName];
cellElem.attr('data-attribute-code', row.attributes[data]['att_code']); if(sPropName === 'value_html')
console.warn('bob'); {
if (row.attributes[data]['value-raw']!== undefined) { cellElem.html(propValue);
cellElem.attr('data-value-raw', row.attributes[data]['value-raw']); }
else if(metadataNames.indexOf(sPropName) > -1)
{
cellElem.attr('data-'+sPropName.replace('_', '-'), propValue)
}
} }
cellElem.html( row.attributes[data].value );
return cellElem.prop('outerHTML'); return cellElem.prop('outerHTML');
}, },