mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°2044: Enable Search form prefill when adding objects to 1:n
This commit is contained in:
@@ -363,13 +363,17 @@ class UILinksWidgetDirect
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for objects to be linked to the current object (i.e "remote" objects)
|
* Search for objects to be linked to the current object (i.e "remote" objects)
|
||||||
|
*
|
||||||
* @param WebPage $oP The page used for the output (usually an AjaxWebPage)
|
* @param WebPage $oP The page used for the output (usually an AjaxWebPage)
|
||||||
* @param string $sRemoteClass Name of the "remote" class to perform the search on, must be a derived class of $this->sLinkedClass
|
* @param string $sRemoteClass Name of the "remote" class to perform the search on, must be a derived class of $this->sLinkedClass
|
||||||
* @param array $aAlreadyLinked Array of indentifiers of objects which are already linke to the current object (or about to be linked)
|
* @param array $aAlreadyLinked Array of indentifiers of objects which are already linke to the current object (or about to be linked)
|
||||||
* @param DBObject $oCurrentObj The object currently being edited... if known...
|
* @param DBObject $oCurrentObj The object currently being edited... if known...
|
||||||
* @throws Exception
|
* @param array $aPrefillFormParam
|
||||||
|
*
|
||||||
|
* @throws \CoreException
|
||||||
|
* @throws \OQLException
|
||||||
*/
|
*/
|
||||||
public function SearchObjectsToAdd(WebPage $oP, $sRemoteClass = '', $aAlreadyLinked = array(), $oCurrentObj = null)
|
public function SearchObjectsToAdd(WebPage $oP, $sRemoteClass = '', $aAlreadyLinked = array(), $oCurrentObj = null, $aPrefillFormParam = array())
|
||||||
{
|
{
|
||||||
if ($sRemoteClass == '')
|
if ($sRemoteClass == '')
|
||||||
{
|
{
|
||||||
@@ -409,6 +413,9 @@ class UILinksWidgetDirect
|
|||||||
|
|
||||||
$aArgs = array_merge($oCurrentObj->ToArgs('this'), $oFilter->GetInternalParams());
|
$aArgs = array_merge($oCurrentObj->ToArgs('this'), $oFilter->GetInternalParams());
|
||||||
$oFilter->SetInternalParams($aArgs);
|
$oFilter->SetInternalParams($aArgs);
|
||||||
|
|
||||||
|
$aPrefillFormParam['filter'] = $oFilter;
|
||||||
|
$oCurrentObj->PrefillForm('search', $aPrefillFormParam);
|
||||||
}
|
}
|
||||||
$oBlock = new DisplayBlock($oFilter, 'list', false);
|
$oBlock = new DisplayBlock($oFilter, 'list', false);
|
||||||
$oBlock->Display($oP, "ResultsToAdd_{$this->sInputid}", array('menu' => false, 'cssCount'=> '#count_'.$this->sInputid , 'selection_mode' => true, 'table_id' => 'add_'.$this->sInputid)); // Don't display the 'Actions' menu on the results
|
$oBlock->Display($oP, "ResultsToAdd_{$this->sInputid}", array('menu' => false, 'cssCount'=> '#count_'.$this->sInputid , 'selection_mode' => true, 'table_id' => 'add_'.$this->sInputid)); // Don't display the 'Actions' menu on the results
|
||||||
|
|||||||
@@ -409,8 +409,16 @@ try
|
|||||||
$oWizardHelper = WizardHelper::FromJSON($sJson);
|
$oWizardHelper = WizardHelper::FromJSON($sJson);
|
||||||
$oObj = $oWizardHelper->GetTargetObject();
|
$oObj = $oWizardHelper->GetTargetObject();
|
||||||
}
|
}
|
||||||
|
$oAppContext = new ApplicationContext();
|
||||||
|
$aPrefillFormParam = array( 'user' => $_SESSION["auth_user"],
|
||||||
|
'context' => $oAppContext->GetAsHash(),
|
||||||
|
'att_code' => $sAttCode,
|
||||||
|
'origin' => 'console',
|
||||||
|
'source_obj' => $oObj,
|
||||||
|
);
|
||||||
|
$aPrefillFormParam['dest_class'] = ($oObj === null ? '' : $oObj->Get($sAttCode)->GetClass());
|
||||||
$oWidget = new UILinksWidgetDirect($sClass, $sAttCode, $iInputId);
|
$oWidget = new UILinksWidgetDirect($sClass, $sAttCode, $iInputId);
|
||||||
$oWidget->SearchObjectsToAdd($oPage, $sRealClass, $aAlreadyLinked, $oObj);
|
$oWidget->SearchObjectsToAdd($oPage, $sRealClass, $aAlreadyLinked, $oObj, $aPrefillFormParam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ui.linksdirectwidget
|
// ui.linksdirectwidget
|
||||||
|
|||||||
Reference in New Issue
Block a user