Skip to content

Commit

Permalink
Merge pull request #816 from hargata/Hargata/refine.sort
Browse files Browse the repository at this point in the history
only add the default sorter once.
  • Loading branch information
hargata authored Jan 21, 2025
2 parents c11dad0 + a4f15ff commit f1f99a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions wwwroot/js/garage.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,11 @@ function sortGarage(sender, isMobile) {
sender.addClass('sort-asc');
sender.html(isMobile ? `<span class="ms-2 display-3">${garageIcon}${sortColumn}${sortAscIcon}</span>` : `${garageIcon}${sortColumn}${sortAscIcon}`);
//append sortRowId to the vehicle container
$(`.garage-item`).map((index, elem) => {
$(elem).attr("default-sort", index);
});
if ($("[default-sort]").length == 0) {
$(`.garage-item`).map((index, elem) => {
$(elem).attr("default-sort", index);
});
}
sortVehicles(false);
}
}
Expand Down
10 changes: 6 additions & 4 deletions wwwroot/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,12 @@ function toggleSort(tabName, sender) {
}
sender.addClass('sort-asc');
sender.html(`${sortColumn}${sortAscIcon}`);
//append sortRowId to the table rows.
$(`#${tabName} table tbody tr`).map((index, elem) => {
$(elem).attr("default-sort", index);
});
//append sortRowId to the table rows if nothing has been appended yet.
if ($("[default-sort]").length == 0) {
$(`#${tabName} table tbody tr`).map((index, elem) => {
$(elem).attr("default-sort", index);
});
}
sortTable(tabName, sortColumn, false);
}
}
Expand Down

0 comments on commit f1f99a6

Please sign in to comment.