Updated variable names for clarity, remove the concat of order and sort

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-01-24 19:08:47 +00:00
parent 165f9545ac
commit dd3b2da670

View file

@ -164,23 +164,24 @@
// Initialize sort-order for bulk actions (label-generation) for snipe-tables // Initialize sort-order for bulk actions (label-generation) for snipe-tables
$('.snipe-table').each(function (i, table) { $('.snipe-table').each(function (i, table) {
table_cookie_segment = $(table).data('cookie-id-table'); table_cookie_segment = $(table).data('cookie-id-table');
name = ''; sort = '';
direction = ''; order = '';
cookies = document.cookie.split(";"); cookies = document.cookie.split(";");
for(i in cookies) { for(i in cookies) {
cookiedef = cookies[i].split("=", 2); cookiedef = cookies[i].split("=", 2);
cookiedef[0] = cookiedef[0].trim(); cookiedef[0] = cookiedef[0].trim();
if (cookiedef[0] == table_cookie_segment + ".bs.table.sortOrder") { if (cookiedef[0] == table_cookie_segment + ".bs.table.sortOrder") {
direction = cookiedef[1]; order = cookiedef[1];
} }
if (cookiedef[0] == table_cookie_segment + ".bs.table.sortName") { if (cookiedef[0] == table_cookie_segment + ".bs.table.sortName") {
name = cookiedef[1]; sort = cookiedef[1];
} }
} }
if (name && direction) { if (sort && order) {
domnode = $($(this).data('bulk-form-id')).get(0); domnode = $($(this).data('bulk-form-id')).get(0);
if ( domnode && domnode.elements && domnode.elements.sort ) { if ( domnode && domnode.elements && domnode.elements.sort ) {
domnode.elements.sort.value = name + " " + direction; domnode.elements.sort.value = sort;
domnode.elements.order.value = order;
} }
} }
}); });
@ -190,7 +191,8 @@
domnode = $($(this).data('bulk-form-id')).get(0); domnode = $($(this).data('bulk-form-id')).get(0);
// make safe in case there isn't a bulk-form-id, or it's not found, or has no 'sort' element // make safe in case there isn't a bulk-form-id, or it's not found, or has no 'sort' element
if ( domnode && domnode.elements && domnode.elements.sort ) { if ( domnode && domnode.elements && domnode.elements.sort ) {
domnode.elements.sort.value = name + " " + order; domnode.elements.sort.value = name;
domnode.elements.order.value = order;
} }
}); });