Search forms enhancement: when a search criteria is an external (foreign) key, use an autocomplete instead of of drop-down list, when the number of different values is too big, as in other forms.

SVN:trunk[1123]
This commit is contained in:
Denis Flaven
2011-03-09 16:39:58 +00:00
parent 692f7060ea
commit bca713a964
6 changed files with 68 additions and 14 deletions

View File

@@ -106,7 +106,11 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
{
// Assumption: $aData['datasource'] will not be null because the data source id is always set...
$sApplicationURL = $aData['datasource']->GetApplicationUrl($this, $aData['replica']);
$sLink = '';
if (!empty($sApplicationURL))
{
$sLink = "<a href=\"$sApplicationURL\" target=\"_blank\">".$aData['datasource']->GetName()."</a>";
}
if ($aData['replica']->Get('status_dest_creator') == 1)
{
$sTip .= "<p>The object was <b>created</b> by the external data source $sLink</p>";
@@ -1062,6 +1066,18 @@ EOF
$aAllowedValues = MetaModel::GetAllowedValues_flt($sClassName, $sFilterCode, $aExtraParams);
if ($aAllowedValues != null)
{
$oAttDef = MetaModel::GetAttributeDef($sClassName, $sFilterCode);
if ($oAttDef->IsExternalKey())
{
$iFieldSize = $oAttDef->GetMaxSize();
$iMaxComboLength = $oAttDef->GetMaximumComboLength();
$oWidget = new UIExtKeyWidget($sFilterCode, $sClassName, $oAttDef->GetLabel(), $aAllowedValues, $sFilterValue, 'search_'.$sFilterCode, false, '', '', '');
$sHtml .= "<label>".MetaModel::GetFilterLabel($sClassName, $sFilterCode).":</label>&nbsp;";
$sHtml .= $oWidget->Display($oPage, $aExtraParams, true /* bSearchMode */);
}
else
{
//Enum field or external key, display a combo
$sValue = "<select name=\"$sFilterCode\">\n";
$sValue .= "<option value=\"\">".Dict::S('UI:SearchValue:Any')."</option>\n";
@@ -1079,6 +1095,7 @@ EOF
}
$sValue .= "</select>\n";
$sHtml .= "<label>".MetaModel::GetFilterLabel($sClassName, $sFilterCode).":</label>&nbsp;$sValue\n";
}
unset($aExtraParams[$sFilterCode]);
}
else