mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Advanced Search
SVN:b1162[5408]
This commit is contained in:
@@ -571,33 +571,6 @@ EOF
|
||||
{
|
||||
$oPage->add_ready_script("oTable.trigger(\"fakesorton\", [$sFakeSortList]);");
|
||||
}
|
||||
//if ($iNbPages == 1)
|
||||
if (false)
|
||||
{
|
||||
if (isset($aExtraParams['cssCount']))
|
||||
{
|
||||
$sCssCount = $aExtraParams['cssCount'];
|
||||
if ($sSelectMode == 'single')
|
||||
{
|
||||
$sSelectSelector = ":radio[name^=selectObj]";
|
||||
}
|
||||
else if ($sSelectMode == 'multiple')
|
||||
{
|
||||
$sSelectSelector = ":checkbox[name^=selectObj]";
|
||||
}
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
$('#{$this->iListId} table.listResults $sSelectSelector').change(function() {
|
||||
var c = $('{$sCssCount}');
|
||||
var v = $('#{$this->iListId} table.listResults $sSelectSelector:checked').length;
|
||||
c.val(v);
|
||||
$('#{$this->iListId} .selectedCount').text(v);
|
||||
c.trigger('change');
|
||||
});
|
||||
EOF
|
||||
);
|
||||
}
|
||||
}
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ EOF
|
||||
$oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
|
||||
$oBlock = new DisplayBlock($oFilter, 'search', false, $aParams);
|
||||
$sHTML .= $oBlock->GetDisplay($oPage, $this->iId,
|
||||
array('open' => $bOpen, 'currentId' => $this->iId, 'table_id' => "dr_{$this->iId}", 'selection_mode' => true, 'selection_type' => 'single'));
|
||||
array('open' => $bOpen, 'currentId' => $this->iId, 'table_id' => "dr_{$this->iId}", 'table_inner_id' => "{$this->iId}_results", 'selection_mode' => true, 'selection_type' => 'single', 'cssCount' => '#count_'.$this->iId));
|
||||
$sHTML .= "<form id=\"fr_{$this->iId}\" OnSubmit=\"return oACWidget_{$this->iId}.DoOk();\">\n";
|
||||
$sHTML .= "<div id=\"dr_{$this->iId}\" 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";
|
||||
|
||||
@@ -386,8 +386,13 @@ EOF
|
||||
/**
|
||||
* @param WebPage $oPage
|
||||
* @param DBObject $oCurrentObj
|
||||
* @param $sJson
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \DictExceptionMissingString
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function GetObjectPickerDialog($oPage, $oCurrentObj)
|
||||
public function GetObjectPickerDialog($oPage, $oCurrentObj, $sJson)
|
||||
{
|
||||
$bOpen = MetaModel::GetConfig()->Get('legacy_search_drawer_open');
|
||||
$sHtml = "<div class=\"wizContainer\" style=\"vertical-align:top;\">\n";
|
||||
@@ -395,7 +400,14 @@ EOF
|
||||
$this->SetSearchDefaultFromContext($oCurrentObj, $oFilter);
|
||||
$oBlock = new DisplayBlock($oFilter, 'search', false);
|
||||
$sHtml .= $oBlock->GetDisplay($oPage, "SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
|
||||
array('open' => $bOpen, 'table_id' => "SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}", 'selection_mode' => true));
|
||||
array(
|
||||
'open' => $bOpen,
|
||||
'table_id' => "SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
|
||||
'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=\"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";
|
||||
|
||||
@@ -269,7 +269,7 @@ try
|
||||
$oObj = null;
|
||||
}
|
||||
$oWidget = new UILinksWidget($sClass, $sAttCode, $iInputId, $sSuffix, $bDuplicates);
|
||||
$oWidget->GetObjectPickerDialog($oPage, $oObj);
|
||||
$oWidget->GetObjectPickerDialog($oPage, $oObj, $sJson);
|
||||
break;
|
||||
|
||||
// ui.linkswidget
|
||||
|
||||
@@ -31,6 +31,7 @@ require_once(APPROOT.'/application/user.preferences.class.inc.php');
|
||||
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
|
||||
require_once(APPROOT.'/sources/application/search/ajaxsearchexception.class.inc.php');
|
||||
require_once(APPROOT.'/sources/application/search/criterionparser.class.inc.php');
|
||||
require_once(APPROOT.'/application/wizardhelper.class.inc.php');
|
||||
|
||||
try
|
||||
{
|
||||
@@ -56,6 +57,10 @@ try
|
||||
$sListParams = stripslashes(utils::ReadParam('list_params', '{}', false, 'raw_data'));
|
||||
$aListParams = json_decode($sListParams, true);
|
||||
|
||||
if (array_key_exists('currentId', $aListParams))
|
||||
{
|
||||
$aExtraParams['currentId'] = $aListParams['currentId'];
|
||||
}
|
||||
if (array_key_exists('selection_mode', $aListParams))
|
||||
{
|
||||
$aExtraParams['selection_mode'] = $aListParams['selection_mode'];
|
||||
@@ -63,12 +68,35 @@ try
|
||||
if (array_key_exists('selection_type', $aListParams))
|
||||
{
|
||||
$aExtraParams['selection_type'] = $aListParams['selection_type'];
|
||||
// In case of single selection, the root of the HTML identifiers used is suffixed with "_results" (at least in the external keys)
|
||||
}
|
||||
if (array_key_exists('json', $aListParams))
|
||||
{
|
||||
$aJson = $aListParams['json'];
|
||||
$sJson = json_encode($aJson);
|
||||
$oWizardHelper = WizardHelper::FromJSON($sJson);
|
||||
$oObj = $oWizardHelper->GetTargetObject();
|
||||
$aExtraParams['query_params'] = array('this' => $oObj);
|
||||
}
|
||||
if (array_key_exists('cssCount', $aListParams))
|
||||
{
|
||||
$aExtraParams['cssCount'] = $aListParams['cssCount'];
|
||||
}
|
||||
if (array_key_exists('table_inner_id', $aListParams))
|
||||
{
|
||||
$sListId = $aListParams['table_inner_id'];
|
||||
}
|
||||
|
||||
$aExtraParams['display_limit'] = true;
|
||||
$aExtraParams['truncated'] = true;
|
||||
$aExtraParams['currentId'] = uniqid('ajax-search-form');
|
||||
$oDisplayBlock->RenderContent($oPage, $aExtraParams);
|
||||
if (isset($sListId))
|
||||
{
|
||||
$oDisplayBlock->Display($oPage, $sListId, $aExtraParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oDisplayBlock->RenderContent($oPage, $aExtraParams);
|
||||
}
|
||||
|
||||
$oPage->output();
|
||||
|
||||
|
||||
@@ -53,17 +53,20 @@ class SearchForm
|
||||
$sHtml = '';
|
||||
$oAppContext = new ApplicationContext();
|
||||
$sClassName = $oSet->GetFilter()->GetClass();
|
||||
$aListParams = array();
|
||||
|
||||
// Simple search form
|
||||
if (isset($aExtraParams['currentId']))
|
||||
{
|
||||
$sSearchFormId = $aExtraParams['currentId'];
|
||||
$aListParams['currentId'] = $aExtraParams['currentId'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$iSearchFormId = $oPage->GetUniqueId();
|
||||
$sSearchFormId = 'SimpleSearchForm'.$iSearchFormId;
|
||||
$sHtml .= "<div id=\"ds_$sSearchFormId\" class=\"mini_tab{$iSearchFormId}\">\n";
|
||||
$aListParams['currentId'] = "$iSearchFormId";
|
||||
}
|
||||
// Check if the current class has some sub-classes
|
||||
if (isset($aExtraParams['baseClass']))
|
||||
@@ -74,7 +77,6 @@ class SearchForm
|
||||
{
|
||||
$sRootClass = $sClassName;
|
||||
}
|
||||
$aListParams = array();
|
||||
if (array_key_exists('selection_mode', $aExtraParams))
|
||||
{
|
||||
$aListParams['selection_mode'] = $aExtraParams['selection_mode'];
|
||||
@@ -84,6 +86,18 @@ class SearchForm
|
||||
$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)
|
||||
{
|
||||
@@ -126,6 +140,11 @@ class SearchForm
|
||||
$aExtraParams['table_id'] = "search_form_result_{$sSearchFormId}";
|
||||
$sHtml .= "<div class=\"display_block\" id=\"search_form_result_{$sSearchFormId}\"></div>\n";
|
||||
}
|
||||
$aListParams['table_id'] = $aExtraParams['table_id'];
|
||||
if (array_key_exists('table_inner_id', $aExtraParams))
|
||||
{
|
||||
$aListParams['table_inner_id'] = $aExtraParams['table_inner_id'];
|
||||
}
|
||||
$aSearchParams = array(
|
||||
'criterion_outer_selector' => "#fs_{$sSearchFormId}_criterion_outer",
|
||||
'result_list_outer_selector' => "#{$aExtraParams['table_id']}",
|
||||
|
||||
Reference in New Issue
Block a user