keep sort order when changing the column, only revert in same colum
This commit is contained in:
parent
5a805aba07
commit
c6c88456cf
@ -98,16 +98,29 @@ function sortBy(column) {
|
||||
document.getElementById(title).innerHTML = upCase(title)
|
||||
)
|
||||
|
||||
// switch direction on every call
|
||||
console.log("col", column)
|
||||
console.log("curcol", currentColumn)
|
||||
|
||||
if (currentColumn === column) {
|
||||
console.log("in switch")
|
||||
// switch direction on every call on same column
|
||||
if (currentSortOrder === 'asc') {
|
||||
currentSortOrder = 'desc'
|
||||
} else {
|
||||
currentSortOrder = 'asc'
|
||||
}
|
||||
console.log("col", column)
|
||||
} else {
|
||||
currentColumn = column
|
||||
}
|
||||
|
||||
let currentTitleElement = document.getElementById(column)
|
||||
let currentTitle = currentTitleElement.innerHTML
|
||||
|
||||
let newTitle
|
||||
|
||||
if (currentSortOrder === 'asc') {
|
||||
currentSortOrder = 'desc'
|
||||
newTitle = currentTitle[0] + currentTitle.substring(1) + ' ⬇'
|
||||
} else {
|
||||
currentSortOrder = 'asc'
|
||||
newTitle = currentTitle[0] + currentTitle.substring(1) + ' ⬆'
|
||||
}
|
||||
currentTitleElement.innerHTML = newTitle
|
||||
@ -183,6 +196,7 @@ function closeError() {
|
||||
|
||||
// global scope
|
||||
let currentSortOrder = 'desc'
|
||||
let currentColumn = 'last'
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const table = document.getElementById('address_table') || false
|
||||
|
Loading…
Reference in New Issue
Block a user