Portal : Fixed search on enum & finalclass as well as display value of enum and html images in lists. Also Fixed display of friendlyname in lists, which was not behaving well on abstract class when the it was composed of several fields in the child classes.

SVN:trunk[4364]
This commit is contained in:
Guillaume Lajarige
2016-09-01 10:29:04 +00:00
parent 2b35cf5047
commit 32dc1225ca
6 changed files with 47 additions and 7 deletions

View File

@@ -561,7 +561,8 @@ class BrowseBrickController extends BrickController
$aRow[$key]['fields'] = array();
foreach ($aLevelsProperties[$key]['fields'] as $aField)
{
$aRow[$key]['fields'][$aField['code']] = $value->Get($aField['code']);
$oAttDef = MetaModel::GetAttributeDef(get_class($value), $aField['code']);
$aRow[$key]['fields'][$aField['code']] = $oAttDef->GetValueLabel($value->Get($aField['code']));
}
}
}

View File

@@ -306,7 +306,7 @@ class ManageBrickController extends BrickController
{
// Set properties
$sCurrentClass = $sKey;
$sTitleAttrCode = MetaModel::GetFriendlyNameAttributeCode($sCurrentClass);
$sTitleAttrCode = 'friendlyname';
// Getting area columns properties
$aColumnsAttrs = $oBrick->GetFields();
@@ -389,7 +389,7 @@ class ManageBrickController extends BrickController
}
else
{
$sValue = $oCurrentRow->Get($sItemAttr);
$sValue = $oAttDef->GetValueLabel($oCurrentRow->Get($sItemAttr));
}
unset($oAttDef);

View File

@@ -32,6 +32,7 @@ use \IssueLog;
use \MetaModel;
use \DBSearch;
use \DBObjectSearch;
use \FalseExpression;
use \BinaryExpression;
use \FieldExpression;
use \VariableExpression;
@@ -39,6 +40,8 @@ use \ListExpression;
use \ScalarExpression;
use \DBObjectSet;
use \cmdbAbstractObject;
use \AttributeEnum;
use \AttributeFinalClass;
use \UserRights;
use \Combodo\iTop\Portal\Helper\ApplicationHelper;
use \Combodo\iTop\Portal\Helper\SecurityHelper;
@@ -873,7 +876,7 @@ class ObjectController extends AbstractController
// - Retrieving class attribute list
$aAttCodes = ApplicationHelper::GetLoadedListFromClass($oApp, $sTargetObjectClass, 'list');
// - Adding friendlyname attribute to the list is not already in it
$sTitleAttCode = MetaModel::GetFriendlyNameAttributeCode($sTargetObjectClass);
$sTitleAttCode = 'friendlyname';
if (($sTitleAttCode !== null) && !in_array($sTitleAttCode, $aAttCodes))
{
$aAttCodes = array_merge(array($sTitleAttCode), $aAttCodes);
@@ -928,7 +931,35 @@ class ObjectController extends AbstractController
$oAttDef = MetaModel::GetAttributeDef($sTargetObjectClass, $aAttCodes[$i]);
$sAttCode = (!$oAttDef->IsExternalKey()) ? $aAttCodes[$i] : $aAttCodes[$i] . '_friendlyname';
// Building expression for the current attcode
$oBinExpr = new BinaryExpression(new FieldExpression($sAttCode, $oSearch->GetClassAlias()), 'LIKE', new VariableExpression('re_query'));
// - For attributes that need conversion from their display value to storage value
// Note : This is dirty hack that will need to be refactored in the OQL core in order to be nicer and to be extended to other types such as dates etc...
if (($oAttDef instanceof AttributeEnum) || ($oAttDef instanceof AttributeFinalClass))
{
// Looking up storage value
$aMatchedCodes = array();
foreach ($oAttDef->GetAllowedValues() as $sValueCode => $sValueLabel)
{
if (stripos($sValueLabel, $sQuery) !== false)
{
$aMatchedCodes[] = $sValueCode;
}
}
// Building expression
if (!empty($aMatchedCodes))
{
$oEnumeratedListExpr = ListExpression::FromScalars($aMatchedCodes);
$oBinExpr = new BinaryExpression(new FieldExpression($sAttCode, $oSearch->GetClassAlias()), 'IN', $oEnumeratedListExpr);
}
else
{
$oBinExpr = new FalseExpression();
}
}
// - For regular attributs
else
{
$oBinExpr = new BinaryExpression(new FieldExpression($sAttCode, $oSearch->GetClassAlias()), 'LIKE', new VariableExpression('re_query'));
}
// Adding expression to the full expression (all attcodes)
if ($i === 0)
{
@@ -1123,7 +1154,7 @@ class ObjectController extends AbstractController
// // - Retrieving class attribute list
// $aAttCodes = MetaModel::FlattenZList(MetaModel::GetZListItems($sTargetObjectClass, 'list'));
// // - Adding friendlyname attribute to the list is not already in it
// $sTitleAttrCode = MetaModel::GetFriendlyNameAttributeCode($sTargetObjectClass);
// $sTitleAttrCode = 'friendlyname';
// if (($sTitleAttrCode !== null) && !in_array($sTitleAttrCode, $aAttCodes))
// {
// $aAttCodes = array_merge(array($sTitleAttrCode), $aAttCodes);

View File

@@ -571,7 +571,7 @@ class ObjectFormManager extends FormManager
// Note : This snippet is inspired from AttributeLinkedSet::MakeFormField()
$aAttCodesToDisplay = ApplicationHelper::GetLoadedListFromClass($this->oApp, $oField->GetTargetClass(), 'list');
// - Adding friendlyname attribute to the list is not already in it
$sTitleAttCode = MetaModel::GetFriendlyNameAttributeCode($oField->GetTargetClass());
$sTitleAttCode = 'friendlyname';
if (($sTitleAttCode !== null) && !in_array($sTitleAttCode, $aAttCodesToDisplay))
{
$aAttCodesToDisplay = array_merge(array($sTitleAttCode), $aAttCodesToDisplay);

View File

@@ -442,6 +442,10 @@ footer {
.dataTables_wrapper {
padding: 10px 10px;
}
.dataTable.table td img {
max-width: 100%;
height: initial !important;
}
#brick_content_toolbar {
/* margin: 10px 0px 6px 0px; */
padding: 10px;

View File

@@ -465,6 +465,10 @@ footer{
.dataTables_wrapper{
padding: 10px 10px;
}
.dataTable.table td img{
max-width: 100%;
height: initial !important;
}
#brick_content_toolbar{
/* margin: 10px 0px 6px 0px; */
padding: 10px;