From 1574504a7c6cff16567619844f77d9df9bc07c8a Mon Sep 17 00:00:00 2001 From: Rick Strafy <45132928+Rixafy@users.noreply.github.com> Date: Wed, 14 Dec 2022 22:54:15 +0100 Subject: [PATCH 1/2] Fix repeating of persistent parameter in url --- assets/datagrid.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/assets/datagrid.js b/assets/datagrid.js index d3c97db7..e12c2576 100644 --- a/assets/datagrid.js +++ b/assets/datagrid.js @@ -354,6 +354,9 @@ for(var p in obj) { if (obj.hasOwnProperty(p)) { var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p]; if (v !== null && v !== "") { + if (window.location.pathname.includes('/' + v)) { + continue; + } if (typeof v == "object") { var r = window.datagridSerializeUrl(v, k); if (r) { From e92ee8a61a263ec6734737e4a1b1fdf19a730f90 Mon Sep 17 00:00:00 2001 From: Rick Strafy <45132928+Rixafy@users.noreply.github.com> Date: Wed, 28 Dec 2022 15:32:52 +0100 Subject: [PATCH 2/2] Improve persistent parameter checking --- assets/datagrid.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/assets/datagrid.js b/assets/datagrid.js index e12c2576..19ebd973 100644 --- a/assets/datagrid.js +++ b/assets/datagrid.js @@ -349,28 +349,32 @@ document.addEventListener('change', function(e) { window.datagridSerializeUrl = function(obj, prefix) { -var str = []; -for(var p in obj) { - if (obj.hasOwnProperty(p)) { - var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p]; - if (v !== null && v !== "") { - if (window.location.pathname.includes('/' + v)) { - continue; - } - if (typeof v == "object") { - var r = window.datagridSerializeUrl(v, k); + const str = []; + let urlPathForPersistentChecking = window.location.pathname; + + for (const p in obj) { + if (obj.hasOwnProperty(p)) { + const k = prefix ? prefix + "[" + p + "]" : p, v = obj[p]; + if (v !== null && v !== "") { + // fix for persistent nette parameters + if (urlPathForPersistentChecking.includes('/' + v)) { + urlPathForPersistentChecking = urlPathForPersistentChecking.replace('/' + v, ''); + continue; + } + if (typeof v == "object") { + const r = window.datagridSerializeUrl(v, k); if (r) { str.push(r); } - } else { - str.push(encodeURIComponent(k) + "=" + encodeURIComponent(v)); + } else { + str.push(encodeURIComponent(k) + "=" + encodeURIComponent(v)); + } } } } -} -return str.join("&"); -} -; + + return str.join("&"); +}; datagridSortable = function() { if (typeof $.fn.sortable === 'undefined') {