FIX_POLICY_TRANSACTION_AUTO_RELOAD_ISSUE

This commit is contained in:
VENKATESHWARAN 2026-07-14 15:49:46 +05:30
parent 21568517c6
commit 3b6aab77ec
2 changed files with 21 additions and 5 deletions

View File

@ -359,14 +359,21 @@
var endorsementListDataTableUrl = '<?= base_url('policy_tranction/endorsement/list/datatable') ?>'; var endorsementListDataTableUrl = '<?= base_url('policy_tranction/endorsement/list/datatable') ?>';
var endorsementClearCacheUrl = '<?= base_url('policy_tranction/endorsement/list/clear-cache') ?>'; var endorsementClearCacheUrl = '<?= base_url('policy_tranction/endorsement/list/clear-cache') ?>';
var endorsementAutoReloadTimer = null; var endorsementAutoReloadTimer = null;
var endorsementTable = null;
function scheduleEndorsementAutoReload(ms) { function scheduleEndorsementAutoReload(ms) {
if (endorsementAutoReloadTimer) { if (endorsementAutoReloadTimer) {
clearTimeout(endorsementAutoReloadTimer); clearTimeout(endorsementAutoReloadTimer);
} }
if (ms > 0) { if (ms > 0) {
console.log('Endorsement auto-reload scheduled in', ms, 'ms (~', Math.round(ms / 1000), 's)');
endorsementAutoReloadTimer = setTimeout(function() { endorsementAutoReloadTimer = setTimeout(function() {
window.location.reload(); console.log('Endorsement auto-reload fired — refreshing table only');
if (endorsementTable) {
endorsementTable.ajax.reload(null, false);
} else {
console.warn('endorsementTable not ready');
}
}, ms); }, ms);
} }
} }
@ -421,7 +428,7 @@
if (ticketsTable.length) { if (ticketsTable.length) {
nhanceListDataTableBeforeInit(); nhanceListDataTableBeforeInit();
var table = ticketsTable.DataTable(nhanceMergeListDataTableOptions({ endorsementTable = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
autoWidth: false, autoWidth: false,
processing: true, processing: true,
serverSide: true, serverSide: true,
@ -441,6 +448,7 @@
return $.extend({}, d, endorsementTableFilters); return $.extend({}, d, endorsementTableFilters);
}, },
dataSrc: function(json) { dataSrc: function(json) {
console.log('cache_expires_in_ms:', json.cache_expires_in_ms);
scheduleEndorsementAutoReload(json.cache_expires_in_ms || 300000); scheduleEndorsementAutoReload(json.cache_expires_in_ms || 300000);
return json.data; return json.data;
} }
@ -524,7 +532,7 @@
ordering: false, ordering: false,
})); }));
nhanceListDataTableAfterInit(); nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(table); nhanceListDataTableBindAdjust(endorsementTable);
} else { } else {
console.error("Table not found."); console.error("Table not found.");
} }

View File

@ -641,14 +641,21 @@ var inceptionTableFilters = <?= json_encode($inception_filters ?? []) ?>;
var inceptionListDataTableUrl = '<?= base_url('policy_tranction/inception/list/datatable') ?>'; var inceptionListDataTableUrl = '<?= base_url('policy_tranction/inception/list/datatable') ?>';
var inceptionClearCacheUrl = '<?= base_url('policy_tranction/inception/list/clear-cache') ?>'; var inceptionClearCacheUrl = '<?= base_url('policy_tranction/inception/list/clear-cache') ?>';
var inceptionAutoReloadTimer = null; var inceptionAutoReloadTimer = null;
var inceptionTable = null;
function scheduleInceptionAutoReload(ms) { function scheduleInceptionAutoReload(ms) {
if (inceptionAutoReloadTimer) { if (inceptionAutoReloadTimer) {
clearTimeout(inceptionAutoReloadTimer); clearTimeout(inceptionAutoReloadTimer);
} }
if (ms > 0) { if (ms > 0) {
console.log('Inception auto-reload scheduled in', ms, 'ms (~', Math.round(ms / 1000), 's)');
inceptionAutoReloadTimer = setTimeout(function() { inceptionAutoReloadTimer = setTimeout(function() {
window.location.reload(); console.log('Inception auto-reload fired — refreshing table only');
if (inceptionTable) {
inceptionTable.ajax.reload(null, false);
} else {
console.warn('inceptionTable not ready');
}
}, ms); }, ms);
} }
} }
@ -717,7 +724,7 @@ $(document).ready(function() {
if (ticketsTable.length) { if (ticketsTable.length) {
nhanceListDataTableBeforeInit(); nhanceListDataTableBeforeInit();
var inceptionTable = ticketsTable.DataTable(nhanceMergeListDataTableOptions({ inceptionTable = ticketsTable.DataTable(nhanceMergeListDataTableOptions({
autoWidth: false, autoWidth: false,
processing: true, processing: true,
serverSide: true, serverSide: true,
@ -737,6 +744,7 @@ $(document).ready(function() {
return $.extend({}, d, inceptionTableFilters); return $.extend({}, d, inceptionTableFilters);
}, },
dataSrc: function(json) { dataSrc: function(json) {
console.log('cache_expires_in_ms:', json.cache_expires_in_ms);
scheduleInceptionAutoReload(json.cache_expires_in_ms || 300000); scheduleInceptionAutoReload(json.cache_expires_in_ms || 300000);
return json.data; return json.data;
} }