N°2654 - Portal: Fix filter on external key when coming from filter brick

This commit is contained in:
Molkobain
2019-12-24 15:05:19 +01:00
parent e27eb7419e
commit 4ddb23cd7c
2 changed files with 33 additions and 3 deletions

View File

@@ -31,6 +31,7 @@ use DBObjectSet;
use BinaryExpression;
use FieldExpression;
use VariableExpression;
use AttributeExternalKey;
use Combodo\iTop\Portal\Brick\AbstractBrick;
use Combodo\iTop\Portal\Brick\BrowseBrick;
@@ -173,9 +174,26 @@ class BrowseBrickController extends BrickController
$aSearchFields = array($aLevelsProperties[$aLevelsPropertiesKeys[$i]]['name_att']);
if (!empty($aLevelsProperties[$aLevelsPropertiesKeys[$i]]['fields']))
{
$sTmpFieldClass = $aLevelsProperties[$aLevelsPropertiesKeys[$i]]['search']->GetClass();
foreach ($aLevelsProperties[$aLevelsPropertiesKeys[$i]]['fields'] as $aTmpField)
{
$aSearchFields[] = $aTmpField['code'];
$sTmpFieldAttCode = $aTmpField['code'];
// Skip invalid attcodes
if(!MetaModel::IsValidAttCode($sTmpFieldClass, $sTmpFieldAttCode))
{
continue;
}
// For external key, force search on the friendlyname instead of the ID.
// This should be addressed more globally with the bigger issue, see N°1970
$oTmpFieldAttDef = MetaModel::GetAttributeDef($sTmpFieldClass, $sTmpFieldAttCode);
if($oTmpFieldAttDef instanceof AttributeExternalKey)
{
$sTmpFieldAttCode .= '_friendlyname';
}
$aSearchFields[] = $sTmpFieldAttCode;
}
}
// - Building query for the search values parts

View File

@@ -23,6 +23,7 @@ namespace Combodo\iTop\Portal\Controller;
use AttributeDate;
use AttributeDateTime;
use AttributeDefinition;
use AttributeExternalKey;
use AttributeImage;
use AttributeTagSet;
use BinaryExpression;
@@ -846,10 +847,21 @@ class ManageBrickController extends BrickController
$aSearchListItems = array();
foreach ($aColumnsAttrs as $sColumnAttr)
{
if (MetaModel::IsValidAttCode($sClass, $sColumnAttr))
// Skip invalid attcodes
if (!MetaModel::IsValidAttCode($sClass, $sColumnAttr))
{
$aSearchListItems[] = $sColumnAttr;
continue;
}
// For external key, force search on the friendlyname instead of the ID.
// This should be addressed more globally with the bigger issue, see N°1970
$oAttDef = MetaModel::GetAttributeDef($sClass, $sColumnAttr);
if($oAttDef instanceof AttributeExternalKey)
{
$sColumnAttr .= '_friendlyname';
}
$aSearchListItems[] = $sColumnAttr;
}
$oFullBinExpr = null;