From 5bc756716e79ceae293db497057ed624f0af983d Mon Sep 17 00:00:00 2001 From: Bruno Da Silva Date: Wed, 14 Mar 2018 11:14:45 +0000 Subject: [PATCH] search widget - ajax endpoint parameter reading refactoring - displayBlock "list" aExtraParams exposition in js SVN:b1162[5424] --- application/displayblock.class.inc.php | 31 ++++++++++++++++++++------ pages/ajax.searchform.php | 6 ++++- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index a740f7cf6..2e10275f7 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -259,7 +259,7 @@ class DisplayBlock if (!$this->m_bAsynchronous) { // render now - $sHtml .= "
\n"; + $sHtml .= "
\n"; $sHtml .= $this->GetRenderContent($oPage, $aExtraParams, $sId); $sHtml .= "
\n"; } @@ -273,9 +273,11 @@ class DisplayBlock $.post("ajax.render.php?style='.$this->m_sStyle.'", { operation: "ajax", filter: "'.$sFilter.'", extra_params: "'.$sExtraParams.'" }, function(data){ - $("#'.$sId.'").empty(); - $("#'.$sId.'").append(data); - $("#'.$sId.'").removeClass("loading"); + $("#'.$sId.'") + .empty() + .append(data) + .removeClass("loading") + ; } ); '); @@ -284,13 +286,28 @@ class DisplayBlock if ($this->m_sStyle != 'search') // Search form need to extract result list extra data, the simplest way is to expose this configuration { - $oPage->add_script("$('#$sId').data('sExtraParams', \"$sExtraParams\");"); - $oPage->add_script("$('#$sId').data('bAutoReload', ".json_encode($bAutoReload).");"); + $oPage->add_ready_script(" + $('#$sId').data('sExtraParams', \"$sExtraParams\"); + $('#$sId').data('bAutoReload', \"$sExtraParams\"); + console.debug($('#$sId').data()); + console.debug($('#$sId')); + console.debug('#$sId'); + + "); + +// $oPage->add_ready_script("console.debug($('#Menu_UserRequest_OpenRequests').data());"); + } if (($bAutoReload) && ($this->m_sStyle != 'search')) // Search form do NOT auto-reload { - $oPage->add_script('aAutoReloadBlock = setInterval("ReloadBlock(\''.$sId.'\', \''.$this->m_sStyle.'\', \''.$sFilter.'\', \"'.$sExtraParams.'\")", '.$iReloadInterval.');'); + $oPage->add_script('if (typeof aAutoReloadBlock == "undefined") { + aAutoReloadBlock = []; + } + if (typeof aAutoReloadBlock[\''.$sId.'\'] != "undefined") { + clearInterval(aAutoReloadBlock[\''.$sId.'\']); + } + aAutoReloadBlock[\''.$sId.'\'] = setInterval("ReloadBlock(\''.$sId.'\', \''.$this->m_sStyle.'\', \''.$sFilter.'\', \"'.$sExtraParams.'\")", '.$iReloadInterval.');'); } return $sHtml; } diff --git a/pages/ajax.searchform.php b/pages/ajax.searchform.php index ad2543132..741d83917 100644 --- a/pages/ajax.searchform.php +++ b/pages/ajax.searchform.php @@ -63,7 +63,6 @@ try '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', - 'table_inner_id', ); foreach ($aPassFromExtraParamsToListParams as $passThroughKey) { @@ -73,6 +72,10 @@ try } } + if (array_key_exists('table_inner_id', $aListParams)) + { + $sListId = $aListParams['table_inner_id']; + } if (array_key_exists('json', $aListParams)) { @@ -90,6 +93,7 @@ try } + $aExtraParams['display_limit'] = true; $aExtraParams['truncated'] = true; if (isset($sListId))