Advanced Search: Auto-complete search on foreign keys + refactoring of table_id2

SVN:b1162[5593]
This commit is contained in:
Eric Espié
2018-04-03 07:37:04 +00:00
parent d4960080ea
commit d22d3945ee
5 changed files with 33 additions and 26 deletions

View File

@@ -333,8 +333,8 @@ class UILinksWidgetDirect
$sHtml .= $oBlock->GetDisplay($oPage, "SearchFormToAdd_{$this->sInputid}",
array(
'open' => $bOpen,
'table_id' => "SearchResultsToAdd_{$this->sInputid}",
'table_id2' => "add_{$this->sInputid}",
'result_list_outer_selector' => "SearchResultsToAdd_{$this->sInputid}",
'table_id' => "add_{$this->sInputid}",
'table_inner_id' => "ResultsToAdd_{$this->sInputid}",
'cssCount' => "#count_{$this->sInputid}",
'query_params' => $oFilter->GetInternalParams(),

View File

@@ -420,8 +420,8 @@ EOF
array(
'open' => $bOpen,
'menu' => false,
'table_id' => "SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
'table_id2' => 'add_'.$this->m_sAttCode,
'result_list_outer_selector' => "SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
'table_id' => 'add_'.$this->m_sAttCode,
'table_inner_id' => "ResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
'selection_mode' => true,
'json' => $sJson,

View File

@@ -53,8 +53,8 @@ class UISearchFormForeignKeys
array(
'open' => $bOpen,
'menu' => false,
'table_id' => "SearchResultsToAdd_{$this->m_iInputId}",
'table_id2' => "add_{$this->m_iInputId}",
'result_list_outer_selector' => "SearchResultsToAdd_{$this->m_iInputId}",
'table_id' => "add_{$this->m_iInputId}",
'table_inner_id' => "ResultsToAdd_{$this->m_iInputId}",
'selection_mode' => true,
'cssCount' => '#count_'.$this->m_sAttCode.$this->m_sNameSuffix,

View File

@@ -255,8 +255,8 @@ function SearchFormForeignKeys(id, sTargetClass, sAttCode, sFilter, sTitle)
// Normal table, retrieve all the checked check-boxes
$(':checked[name^=selectObject]', context).each(
function (i) {
if ((this.name != '') && ((this.type != 'checkbox') || (this.checked))) {
arrayExpr = /\[\]$/;
if ((this.name !== '') && ((this.type !== 'checkbox') || (this.checked))) {
var arrayExpr = /\[\]$/;
if (arrayExpr.test(this.name)) {
// Array
if (typeof theMap[this.name] === "undefined") {

View File

@@ -91,6 +91,18 @@ class SearchForm
$aListParams['json'] = json_decode($sJson, true);
}
if (!isset($aExtraParams['result_list_outer_selector']))
{
if (isset($aExtraParams['table_id']))
{
$aExtraParams['result_list_outer_selector'] = $aExtraParams['table_id'];
}
else
{
$aExtraParams['result_list_outer_selector'] = "search_form_result_{$sSearchFormId}";
}
}
$aSubClasses = MetaModel::GetSubclasses($sRootClass);
if (count($aSubClasses) > 0)
@@ -104,7 +116,7 @@ class SearchForm
$aOptions[MetaModel::GetName($sClassName)] = "<option selected value=\"$sClassName\">".MetaModel::GetName($sClassName)."</options>\n";
ksort($aOptions);
$sContext = $oAppContext->GetForLink();
$sClassesCombo = "<select name=\"class\" onChange=\"ReloadSearchForm('$sSearchFormId', this.value, '$sRootClass', '$sContext', '{$aExtraParams['table_id']}')\">\n".implode('',
$sClassesCombo = "<select name=\"class\" onChange=\"ReloadSearchForm('$sSearchFormId', this.value, '$sRootClass', '$sContext', '{$aExtraParams['result_list_outer_selector']}')\">\n".implode('',
$aOptions)."</select>\n";
}
else
@@ -148,28 +160,19 @@ class SearchForm
$oBaseSearch->ResetCondition();
$sBaseOQL = str_replace(' WHERE 1', '', $oBaseSearch->ToOQL());
if (isset($aExtraParams['table_inner_id']))
{
$sDataConfigListSelector = $aExtraParams['table_inner_id'];
}
else
{
$sDataConfigListSelector = $aExtraParams['table_id'];
}
if (!isset($aExtraParams['table_id']))
{
$aExtraParams['table_id'] = "search_form_result_{$sSearchFormId}";
$sDataConfigListSelector = $aExtraParams['result_list_outer_selector'];
}
if (!isset($aExtraParams['table_inner_id']))
{
$aListParams['table_inner_id'] = "table_inner_id_{$sSearchFormId}";
}
// When table_id is different of result_list_outer_selector
if (isset($aExtraParams['table_id2']))
{
$aListParams['table_id'] = $aExtraParams['table_id2'];
}
$bOpen = false;
if (isset($aExtraParams['open']))
{
@@ -189,7 +192,7 @@ class SearchForm
$aSearchParams = array(
'criterion_outer_selector' => "#fs_{$sSearchFormId}_criterion_outer",
'result_list_outer_selector' => "#{$aExtraParams['table_id']}",
'result_list_outer_selector' => "#{$aExtraParams['result_list_outer_selector']}",
'data_config_list_selector' => "#{$sDataConfigListSelector}",
'endpoint' => utils::GetAbsoluteUrlAppRoot().'pages/ajax.searchform.php',
'init_opened' => $bOpen,
@@ -327,9 +330,10 @@ class SearchForm
}
$oSearch->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true);
$oSet = new DBObjectSet($oSearch);
if ($oSet->Count() > MetaModel::GetConfig()->Get('max_combo_length'))
$iCount = $oSet->Count();
if ($iCount > MetaModel::GetConfig()->Get('max_combo_length'))
{
return array('autocomplete' => true);
return array('autocomplete' => true, 'count' => $iCount);
}
}
else
@@ -337,14 +341,17 @@ class SearchForm
if (method_exists($oAttrDef, 'GetAllowedValuesAsObjectSet'))
{
$oSet = $oAttrDef->GetAllowedValuesAsObjectSet();
if ($oSet->Count() > MetaModel::GetConfig()->Get('max_combo_length'))
$iCount = $oSet->Count();
if ($iCount > MetaModel::GetConfig()->Get('max_combo_length'))
{
return array('autocomplete' => true);
return array('autocomplete' => true, 'count' => $iCount);
}
}
}
return array('values' => $oAttrDef->GetAllowedValues());
$aAllowedValues = $oAttrDef->GetAllowedValues();
return array('values' => $aAllowedValues, 'count' => count($aAllowedValues));
}
/**