N°7146 - Fix style not applied in list in the end-users portal in iTop 3.0+ - Add Markup in search list in order to use style

This commit is contained in:
Anne-Cath
2024-03-15 17:03:14 +01:00
committed by Molkobain
parent c910d35e25
commit 1bb3fe5e0a
2 changed files with 27 additions and 11 deletions

View File

@@ -1408,14 +1408,15 @@ class ObjectController extends BrickController
protected function PrepareObjectInformation(DBObject $oObject, $aAttCodes = array())
{
$sObjectClass = get_class($oObject);
$aObjectData = array(
'id' => $oObject->GetKey(),
'name' => $oObject->GetName(),
'attributes' => array(),
);
$aObjectData = [
'id' => $oObject->GetKey(),
'object_class' => $sObjectClass,
'name' => $oObject->GetName(),
'attributes' => [],
];
// Retrieving attributes definitions
$aAttDefs = array();
$aAttDefs = [];
foreach ($aAttCodes as $sAttCode)
{
if ($sAttCode === 'id')
@@ -1429,9 +1430,15 @@ class ObjectController extends BrickController
// Preparing attribute data
foreach ($aAttDefs as $oAttDef)
{
$aAttData = array(
$aAttData = [
'att_code' => $oAttDef->GetCode(),
);
'attribute-type' => get_class($oAttDef),
];
// - Value raw
if ($oAttDef::IsScalar()) {
$aAttData['value-raw'] =utils::HtmlEntities( (string)$oObject->Get($oAttDef->GetCode()));
}
if ($oAttDef->IsExternalKey())
{

View File

@@ -9,7 +9,7 @@
<div id="{{ sFormId }}">
{#<div class="form_alerts"></div>#}
<div class="form_fields">
<table id="{{ sTableId }}" class="table table-striped table-bordered responsive" cellspacing="0" width="100%">
<table id="{{ sTableId }}" class="object-list table table-striped table-bordered responsive" cellspacing="0" width="100%">
<tbody>
</tbody>
</table>
@@ -80,7 +80,17 @@
{
cellElem = $('<span></span>');
}
cellElem.attr('data-object-id', row.id).html('<span>' + row.attributes[data].value + '</span>');
//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']);
}
cellElem.html( row.attributes[data].value );
return cellElem.prop('outerHTML');
},
@@ -92,7 +102,6 @@
$(document).ready(function(){
showTableLoader();
// Note : Those options should be externalized in an library so we can use them on any DataTables for the portal.
// We would just have to override / complete the necessary elements
oTable = $('#{{ sTableId }}').DataTable({