Merge branch 'master' into develop

This commit is contained in:
Pierre Goiffon
2019-05-13 08:54:00 +02:00
6 changed files with 52 additions and 19 deletions

View File

@@ -1172,16 +1172,26 @@ EOF
}
if (($bAutoReload) && ($this->m_sStyle != 'search')) // Search form do NOT auto-reload
{
$sFilter = addslashes(str_replace('"', "'", $this->m_oFilter->serialize())); // Used either for asynchronous or auto_reload
$sExtraParams = addslashes(str_replace('"', "'", json_encode($aExtraParams))); // JSON encode, change the style of the quotes and escape them
// Used either for asynchronous or auto_reload
// does a json_encode twice to get a string usable as function parameter
$sFilterBefore = $this->m_oFilter->serialize();
$sFilter = json_encode($sFilterBefore);
$sExtraParams = json_encode(json_encode($aExtraParams));
$oPage->add_script('if (typeof window.oAutoReloadBlock == "undefined") {
window.oAutoReloadBlock = {};
}
if (typeof window.oAutoReloadBlock[\''.$sId.'\'] != "undefined") {
clearInterval(window.oAutoReloadBlock[\''.$sId.'\']);
}
window.oAutoReloadBlock[\''.$sId.'\'] = setInterval("ReloadBlock(\''.$sId.'\', \''.$this->m_sStyle.'\', \"'.$sFilter.'\", \"'.$sExtraParams.'\")", '.$iReloadInterval.');');
$oPage->add_script(
<<<JS
if (typeof window.oAutoReloadBlock == "undefined") {
window.oAutoReloadBlock = {};
}
if (typeof window.oAutoReloadBlock['$sId'] != "undefined") {
clearInterval(window.oAutoReloadBlock['$sId']);
}
window.oAutoReloadBlock['$sId'] = setInterval(function() {
ReloadBlock('$sId', '{$this->m_sStyle}', $sFilter, $sExtraParams);
}, '$iReloadInterval');
JS
);
}
return $sHtml;

View File

@@ -234,7 +234,7 @@ function MakeDataToPost($sTargetRoute)
if (MetaModel::GetConfig()->Get('demo_mode'))
{
// Don't expose such information in demo mode
$aDataToPost = array();
$aDataToPost = array('disabled' => true, 'reason' => 'demo_mode');
}
else
{
@@ -466,4 +466,4 @@ catch (Exception $e)
IssueLog::Error($e->getMessage());
}
}

View File

@@ -285,9 +285,9 @@ function sprintf(format, etc) {
}
});
$(table).find(':checkbox[name^=selectObj]').change(function() {
$(table).find(':checkbox[name^=selectObj]').on("change init-selection", function () {
storeSelection(table, table.config.container, this.value, this.checked, this.disabled);
}).trigger("change");
}).trigger("init-selection"); // don't need to trigger the very generic change event !
}
else if (table.config.select_mode == 'single')
{

View File

@@ -59,8 +59,14 @@ $(document).ready(function () {
$lineClickedInput.click();
});
$(document).on('change', TABLE_SELECTOR+':has('+LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR+')', function (event) {
$(document).on('change', TABLE_SELECTOR, function (event) {
var $eventTarget = $(event.target);
if (!$eventTarget.has(LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR))
// Originally we had :has in the handler selector but performances were very bad :(
// Filtering directly in JQuery is far much quicker ! => N°2192
{
return;
}
if (!$eventTarget.is(INPUT_SELECTOR)) {
return;
}
@@ -69,7 +75,14 @@ $(document).ready(function () {
});
// check_all event is fired for tableSorter JQuery plugin
$(document).on("check_all", TABLE_SELECTOR+':has('+LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR+')', function () {
$(document).on("check_all", TABLE_SELECTOR, function (event) {
var $eventTarget = $(event.target);
if (!$eventTarget.has(LINE_WITH_INPUT_IN_FIRST_CELL_SELECTOR))
// Originally we had :has in the handler selector but performances were very bad :(
// Filtering directly in JQuery is far much quicker ! => N°2192
{
return;
}
$(this).find("tbody>tr").addClass(SELECTED_CLASS);
});
@@ -105,8 +118,9 @@ $(document).ready(function () {
function updateLines($inputChanged) {
var $selectedLine = $inputChanged.closest("tr");
if ($inputChanged.is('input:radio')) {
// didn't find a proper event fired when radio is deselected... so doing this !
// didn't find a proper event fired when radio is deselected... so doing this !
if ($inputChanged.is('input:radio'))
{
$selectedLine
.closest('table')
.find('tr')

View File

@@ -199,7 +199,7 @@ function ReloadBlock(divId, sStyle, sSerializedFilter, sExtraParams) {
$('#'+divId).block();
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php?style='+sStyle,
{operation: 'ajax', filter: sSerializedFilter, extra_params: sExtraParams},
{operation: 'ajax', filter: sSerializedFilter, encoding: 'serialize', extra_params: sExtraParams},
function (data) {
$('#'+divId).empty();
$('#'+divId).append(data);

View File

@@ -743,7 +743,16 @@ try
}
else
{
$oFilter = DBSearch::unserialize($sFilter);
try
{
$oFilter = DBSearch::unserialize($sFilter);
}
catch (CoreException $e)
{
$oPage->p("Invalid query (invalid filter) : <code>$sFilter</code>");
IssueLog::Error("ajax.render operation='ajax', invalid DBSearch filter param : $sFilter");
break;
}
}
$oDisplayBlock = new DisplayBlock($oFilter, $sStyle, false);
$aExtraParams['display_limit'] = true;