mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
Advanced Search: Links n:n
SVN:b1162[5438]
This commit is contained in:
@@ -387,36 +387,42 @@ EOF
|
||||
* @param WebPage $oPage
|
||||
* @param DBObject $oCurrentObj
|
||||
* @param $sJson
|
||||
* @param array $aAlreadyLinkedIds
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \DictExceptionMissingString
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function GetObjectPickerDialog($oPage, $oCurrentObj, $sJson)
|
||||
public function GetObjectPickerDialog($oPage, $oCurrentObj, $sJson, $aAlreadyLinkedIds = array())
|
||||
{
|
||||
$bOpen = MetaModel::GetConfig()->Get('legacy_search_drawer_open');
|
||||
$sHtml = "<div class=\"wizContainer\" style=\"vertical-align:top;\">\n";
|
||||
$oFilter = new DBObjectSearch($this->m_sRemoteClass);
|
||||
$this->SetSearchDefaultFromContext($oCurrentObj, $oFilter);
|
||||
if (!$this->m_bDuplicatesAllowed && count($aAlreadyLinkedIds) > 0)
|
||||
{
|
||||
$oFilter->AddCondition('id', $aAlreadyLinkedIds, 'NOTIN');
|
||||
}
|
||||
//$this->SetSearchDefaultFromContext($oCurrentObj, $oFilter);
|
||||
$oBlock = new DisplayBlock($oFilter, 'search', false);
|
||||
$sHtml .= $oBlock->GetDisplay($oPage, "SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
|
||||
array(
|
||||
'menu' => false,
|
||||
'open' => $bOpen,
|
||||
'table_id' => "SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
|
||||
'table_id2' => 'add_'.$this->m_sAttCode,
|
||||
'table_inner_id' => "ResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
|
||||
'selection_mode' => true,
|
||||
'json' => $sJson,
|
||||
'cssCount' => '#count_'.$this->m_sAttCode.$this->m_sNameSuffix
|
||||
));
|
||||
$sHtml .= "<form id=\"ObjectsAddForm_{$this->m_sAttCode}{$this->m_sNameSuffix}\" OnSubmit=\"return oWidget{$this->m_iInputId}.DoAddObjects(this.id);\">\n";
|
||||
$sHtml .= "<div id=\"ObjectsAddForm_{$this->m_sAttCode}{$this->m_sNameSuffix}\">\n";
|
||||
$sHtml .= "<div id=\"SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}\" style=\"vertical-align:top;background: #fff;height:100%;overflow:auto;padding:0;border:0;\">\n";
|
||||
$sHtml .= "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>".Dict::S('UI:Message:EmptyList:UseSearchForm')."</p></div>\n";
|
||||
$sHtml .= "</div>\n";
|
||||
$sHtml .= "<input type=\"hidden\" id=\"count_{$this->m_sAttCode}{$this->m_sNameSuffix}\" value=\"0\"/>";
|
||||
$sHtml .= "<input type=\"button\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('close');\"> <input id=\"btn_ok_{$this->m_sAttCode}{$this->m_sNameSuffix}\" disabled=\"disabled\" type=\"submit\" value=\"".Dict::S('UI:Button:Add')."\">";
|
||||
$sHtml .= "<input type=\"button\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('close');\"> <input id=\"btn_ok_{$this->m_sAttCode}{$this->m_sNameSuffix}\" disabled=\"disabled\" type=\"button\" onclick=\"return oWidget{$this->m_iInputId}.DoAddObjects(this.id);\" value=\"".Dict::S('UI:Button:Add')."\">";
|
||||
$sHtml .= "</div>\n";
|
||||
$sHtml .= "</div>\n";
|
||||
$sHtml .= "</form>\n";
|
||||
$oPage->add($sHtml);
|
||||
$oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, resizeStop: oWidget{$this->m_iInputId}.UpdateSizes });");
|
||||
$oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('option', {title:'".addslashes(Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName($this->m_sClass)))."'});");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -57,19 +57,9 @@ try
|
||||
$sListParams = stripslashes(utils::ReadParam('list_params', '{}', false, 'raw_data'));
|
||||
$aListParams = (array) json_decode($sListParams, true);
|
||||
|
||||
|
||||
$aPassFromExtraParamsToListParams = array(
|
||||
'currentId',
|
||||
'selection_mode',
|
||||
'selection_type',// In case of single selection, the root of the HTML identifiers used is suffixed with "_results" (at least in the external keys)
|
||||
'cssCount',
|
||||
);
|
||||
foreach ($aPassFromExtraParamsToListParams as $passThroughKey)
|
||||
foreach($aListParams as $key => $value)
|
||||
{
|
||||
if (array_key_exists($passThroughKey, $aListParams))
|
||||
{
|
||||
$aExtraParams[$passThroughKey] = $aListParams[$passThroughKey];
|
||||
}
|
||||
$aExtraParams[$key] = $value;
|
||||
}
|
||||
|
||||
if (array_key_exists('table_inner_id', $aListParams))
|
||||
|
||||
@@ -61,11 +61,15 @@ class SearchForm
|
||||
$sClassName = $oSet->GetFilter()->GetClass();
|
||||
$aListParams = array();
|
||||
|
||||
foreach($aExtraParams as $key => $value)
|
||||
{
|
||||
$aListParams[$key] = $value;
|
||||
}
|
||||
|
||||
// Simple search form
|
||||
if (isset($aExtraParams['currentId']))
|
||||
{
|
||||
$sSearchFormId = $aExtraParams['currentId'];
|
||||
$aListParams['currentId'] = $aExtraParams['currentId'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -83,23 +87,13 @@ class SearchForm
|
||||
{
|
||||
$sRootClass = $sClassName;
|
||||
}
|
||||
if (array_key_exists('selection_mode', $aExtraParams))
|
||||
{
|
||||
$aListParams['selection_mode'] = $aExtraParams['selection_mode'];
|
||||
}
|
||||
if (array_key_exists('selection_type', $aExtraParams))
|
||||
{
|
||||
$aListParams['selection_type'] = $aExtraParams['selection_type'];
|
||||
}
|
||||
|
||||
$sJson = stripslashes(utils::ReadParam('json', '', false, 'raw_data'));
|
||||
if (!empty($sJson))
|
||||
{
|
||||
$aListParams['json'] = json_decode($sJson, true);
|
||||
}
|
||||
if (array_key_exists('cssCount', $aExtraParams))
|
||||
{
|
||||
$aListParams['cssCount'] = $aExtraParams['cssCount'];
|
||||
}
|
||||
|
||||
|
||||
$aSubClasses = MetaModel::GetSubclasses($sRootClass);
|
||||
if (count($aSubClasses) > 0)
|
||||
@@ -139,15 +133,14 @@ class SearchForm
|
||||
{
|
||||
$aExtraParams['table_id'] = "search_form_result_{$sSearchFormId}";
|
||||
}
|
||||
$aListParams['table_id'] = $aExtraParams['table_id'];
|
||||
if (array_key_exists('table_inner_id', $aExtraParams))
|
||||
{
|
||||
$aListParams['table_inner_id'] = $aExtraParams['table_inner_id'];
|
||||
}
|
||||
else
|
||||
if (!array_key_exists('table_inner_id', $aExtraParams))
|
||||
{
|
||||
$aListParams['table_inner_id'] = uniqid('table_inner_id_');
|
||||
}
|
||||
if (array_key_exists('table_id2', $aExtraParams))
|
||||
{
|
||||
$aListParams['table_id'] = $aExtraParams['table_id2'];
|
||||
}
|
||||
$aSearchParams = array(
|
||||
'criterion_outer_selector' => "#fs_{$sSearchFormId}_criterion_outer",
|
||||
'result_list_outer_selector' => "#{$aExtraParams['table_id']}",
|
||||
@@ -162,13 +155,13 @@ class SearchForm
|
||||
),
|
||||
);
|
||||
|
||||
if (isset($aSearchParams['list_params']['table_inner_id']))
|
||||
{
|
||||
$aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['list_params']['table_inner_id'];
|
||||
}
|
||||
elseif (isset($aSearchParams['list_params']['table_id']))
|
||||
{
|
||||
$aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['list_params']['table_id'];
|
||||
if (isset($aSearchParams['list_params']['table_id']))
|
||||
{
|
||||
$aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['list_params']['table_id'];
|
||||
}
|
||||
elseif (isset($aSearchParams['list_params']['table_inner_id']))
|
||||
{
|
||||
$aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['list_params']['table_inner_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user