Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix repeating of persistent parameter in url #1055

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 20 additions & 13 deletions assets/datagrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,25 +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 (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') {
Expand Down