diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 6da6d6985..4689c1c21 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -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 = "".$aData['datasource']->GetName().""; + } if ($aData['replica']->Get('status_dest_creator') == 1) { $sTip .= "

The object was created by the external data source $sLink

"; @@ -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 .= " "; + $sHtml .= $oWidget->Display($oPage, $aExtraParams, true /* bSearchMode */); + } + else + { //Enum field or external key, display a combo $sValue = "\n"; $sHtml .= " $sValue\n"; + } unset($aExtraParams[$sFilterCode]); } else diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index 6ebe4684c..a0376d4e4 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -92,12 +92,24 @@ class UIExtKeyWidget * @param Hash $aArgs Extra context arguments * @return string The HTML fragment to be inserted into the page */ - public function Display(WebPage $oPage, $aArgs = array()) + public function Display(WebPage $oPage, $aArgs = array(), $bSearchMode = false) { - $bCreate = (!MetaModel::IsAbstract($this->sTargetClass)) && (UserRights::IsActionAllowed($this->sTargetClass, UR_ACTION_BULK_MODIFY) && $this->oAttDef->AllowTargetCreation()); + $oPage->add_linked_script('../js/extkeywidget.js'); + $oPage->add_linked_script('../js/forms-json-utils.js'); + + $bCreate = (!$bSearchMode) && (!MetaModel::IsAbstract($this->sTargetClass)) && (UserRights::IsActionAllowed($this->sTargetClass, UR_ACTION_BULK_MODIFY) && $this->oAttDef->AllowTargetCreation()); $sMessage = Dict::S('UI:Message:EmptyList:UseSearchForm'); + $sAttrFieldPrefix = ($bSearchMode) ? '' : 'attr_'; $sHTMLValue = ""; // no wrap + if($bSearchMode) + { + $sWizHelper = 'null'; + } + else + { + $sWizHelper = 'oWizardHelper'.$this->sFormPrefix; + } if (count($this->aAllowedValues) < $this->oAttDef->GetMaximumComboLength()) { // Few choices, use a normal 'select' @@ -106,8 +118,15 @@ class UIExtKeyWidget $sHelpText = $this->oAttDef->GetHelpOnEdition(); // In case there are no valid values, the select will be empty, thus blocking the user from validating the form - $sHTMLValue = "sFieldPrefix}{$this->sAttCode}{$this->sNameSuffix}\" id=\"$this->iId\">\n"; + if ($bSearchMode) + { + $sHTMLValue .= "\n"; + } + else + { + $sHTMLValue .= "\n"; + } foreach($this->aAllowedValues as $key => $display_value) { if ((count($this->aAllowedValues) == 1) && ($this->bMandatory == 'true') ) @@ -122,9 +141,9 @@ class UIExtKeyWidget $sHTMLValue .= "\n"; } $sHTMLValue .= "\n"; - $oPage->add_ready_script( + $oPage->add_ready_script( <<iId} = new ExtKeyWidget('{$this->iId}', '{$this->sClass}', '{$this->sAttCode}', '{$this->sNameSuffix}', $sSelectMode, oWizardHelper{$this->sFormPrefix}); + oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sClass}', '{$this->sAttCode}', '{$this->sNameSuffix}', $sSelectMode, $sWizHelper); oACWidget_{$this->iId}.emptyHtml = "

$sMessage

"; EOF @@ -152,12 +171,12 @@ EOF $sHTMLValue .= "iId}.Search();\"> "; // another hidden input to store & pass the object's Id - $sHTMLValue .= "iId\" name=\"attr_{$this->sFieldPrefix}{$this->sAttCode}{$this->sNameSuffix}\" value=\"$this->value\" />\n"; + $sHTMLValue .= "iId\" name=\"{$sAttrFieldPrefix}{$this->sFieldPrefix}{$this->sAttCode}{$this->sNameSuffix}\" value=\"$this->value\" />\n"; // Scripts to start the autocomplete and bind some events to it $oPage->add_ready_script( <<iId} = new ExtKeyWidget('{$this->iId}', '{$this->sClass}', '{$this->sAttCode}', '{$this->sNameSuffix}', $sSelectMode, oWizardHelper{$this->sFormPrefix}); + oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sClass}', '{$this->sAttCode}', '{$this->sNameSuffix}', $sSelectMode, $sWizHelper); oACWidget_{$this->iId}.emptyHtml = "

$sMessage

"; $('#label_$this->iId').autocomplete('./ajax.render.php', { scroll:true, minChars:{$iMinChars}, formatItem:formatItem, autoFill:false, matchContains:true, keyHolder:'#{$this->iId}', extraParams:{operation:'autocomplete', sclass:'{$this->sClass}',attCode:'{$this->sAttCode}'}}); $('#label_$this->iId').blur(function() { $(this).search(); } ); diff --git a/core/config.class.inc.php b/core/config.class.inc.php index b89c0a992..af47849b8 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -125,7 +125,7 @@ class Config 'show_in_conf_sample' => true, ), 'max_combo_length' => array( - 'type' => 'int', + 'type' => 'integer', 'description' => 'The maximum number of elements in a drop-down list. If more then an autocomplete will be used', 'default' => 50, 'value' => 50, @@ -133,7 +133,7 @@ class Config 'show_in_conf_sample' => false, ), 'min_autocomplete_chars' => array( - 'type' => 'int', + 'type' => 'integer', 'description' => 'The minimum number of characters to type in order to trigger the "autocomplete" behavior', 'default' => 3, 'value' => 3, diff --git a/css/light-grey.css b/css/light-grey.css index 37afbf0a0..c5b8862cc 100644 --- a/css/light-grey.css +++ b/css/light-grey.css @@ -160,7 +160,7 @@ p a:hover, td a:hover { background: url(../images/mini-arrow-orange.gif) no-repeat left; } -td a.no-arrow, td a.no-arrow:visited { +td a.no-arrow, td a.no-arrow:visited, .SearchDrawer a.no-arrow, .SearchDrawer a.no-arrow:visited { text-decoration:none; color:#000000; padding-left:0px; diff --git a/js/extkeywidget.js b/js/extkeywidget.js index 04210d1a4..e66ea96b4 100644 --- a/js/extkeywidget.js +++ b/js/extkeywidget.js @@ -97,8 +97,16 @@ function ExtKeyWidget(id, sClass, sAttCode, sSuffix, bSelectMode, oWizHelper) } ); - me.oWizardHelper.UpdateWizard(); - theMap['json'] = me.oWizardHelper.ToJSON(); + if (me.oWizardHelper == null) + { + theMap['json'] = ''; + } + else + { + // Not inside a "search form", updating a real object + me.oWizardHelper.UpdateWizard(); + theMap['json'] = me.oWizardHelper.ToJSON(); + } theMap['sRemoteClass'] = theMap['class']; // swap 'class' (defined in the form) and 'remoteClass' theMap['class'] = me.sClass; diff --git a/pages/ajax.render.php b/pages/ajax.render.php index fc75d3f3e..c07bb825e 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -79,10 +79,20 @@ try $iInputId = utils::ReadParam('iInputId', ''); $sSuffix = utils::ReadParam('sSuffix', ''); $sJson = utils::ReadParam('json', ''); + if (!empty($sJson)) + { $oWizardHelper = WizardHelper::FromJSON($sJson); $oObj = $oWizardHelper->GetTargetObject(); + $currentValue = $oObj->Get($sAttCode); + } + else + { + // Search form: no current object + $oObj = null; + $currentValue = 'eviV bulgroZ'; + } $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array('this' => $oObj)); - $oWidget = new UIExtKeyWidget($sAttCode, $sClass, '', $aAllowedValues, $oObj->Get($sAttCode), $iInputId, false, $sSuffix, ''); + $oWidget = new UIExtKeyWidget($sAttCode, $sClass, '', $aAllowedValues, $currentValue, $iInputId, false, $sSuffix, ''); $oWidget->SearchObjectsToSelect($oPage, $sTargetClass); break;