Added indicator to show if sorting is ascending or descending
This commit is contained in:
parent
8bc252ba4d
commit
4ed3dcd603
@ -73,14 +73,30 @@ function deleteAddress(id) {
|
||||
}
|
||||
}
|
||||
|
||||
function upCase(text) {
|
||||
return text[0].toUpperCase() + text.substring(1);
|
||||
}
|
||||
function sortBy(column) {
|
||||
// clear titles
|
||||
const titles = ['first', 'last', 'street', 'zip', 'city', 'phone']
|
||||
titles.forEach((title) =>
|
||||
document.getElementById(title).innerHTML = upCase(title)
|
||||
)
|
||||
|
||||
// switch direction on every call
|
||||
let currentSortOrder = document.getElementById(column + '_sort')
|
||||
let currentSortOrder = document.getElementById(column + '_sort')
|
||||
let currentTitleElement = document.getElementById(column)
|
||||
let currentTitle = currentTitleElement.innerHTML
|
||||
|
||||
let newTitle = ''
|
||||
if (currentSortOrder.innerHTML === 'asc') {
|
||||
currentSortOrder.innerHTML = 'desc'
|
||||
newTitle = currentTitle[0] + currentTitle.substring(1) + ' ⬇'
|
||||
} else {
|
||||
currentSortOrder.innerHTML = 'asc'
|
||||
newTitle = currentTitle[0] + currentTitle.substring(1) + ' ⬆'
|
||||
}
|
||||
currentTitleElement.innerHTML = newTitle
|
||||
|
||||
const table = document.getElementById('address_table');
|
||||
let dirty = true;
|
||||
|
Loading…
Reference in New Issue
Block a user