Skip to content

Commit

Permalink
change selectAll button to select current entries
Browse files Browse the repository at this point in the history
With the added filtering option the "select all" button could be a bit confusing as it also selects all accouts that are not visible when a specific keyword is active.

This commit changes it, so that only the currently visible accounts are selected, when select all is clicked.

For me this seems more intuitive, but is it?

relates to #15
  • Loading branch information
trutzig89182 committed Nov 21, 2022
1 parent b779fed commit cbfa429
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@ async function getCSVData () {
}

/**
* Selects all checkboxes on the page
* Selects checkboxes currently displayed on the webpage
*/
function selectAllUsers () {
for (const checkbox of allCheckboxes()) {
checkbox.checked = true
console.log(checkbox.parentElement.getAttribute('style'))
if (checkbox.parentElement.getAttribute('style') == 'display: normal;') {
console.log("a checkbox was checked")
checkbox.checked = true
}
}
}

Expand Down Expand Up @@ -187,7 +191,6 @@ function buildUserSelectionForm (users) {
const keyword_item = document.createElement('a')
keyword_item.textContent = keywordArray[i].replaceAll("_", " ").toLowerCase()
keyword_item.setAttribute('selected', false)
console.log('create new attribute selected = false for keyword')
keyword_item.setAttribute('name', keywordArray[i].toLowerCase())
keyword_item.setAttribute('onclick', 'selectedKeyword(this)')
keyword_item.setAttribute('class', 'keywordclass')
Expand Down Expand Up @@ -273,21 +276,20 @@ function filterByKeyword (keywordElement) {

// sets all elements to not selected and invisible before making only selected elements visible
for (var i = 0; i < checkboxListElements.length; i++) {
//console.log('set to invisible')
// why is the syntax here different than below where setAttribute() is used? didn’t seem to work here.
checkboxListElements.item(i).style.display = 'none' //setAttribute('style', 'diplay: none;')
//console.log(checkboxListElements.item(i).getAttribute('style'))
}

// setzt alle keyword.selected auf false (um dann nur die keywords, die dem aktuellen entsprechen auf true zu setzen.)
for (var i = 0; i < allKeywordElements.length; i++) {
allKeywordElements.item(i).setAttribute('selected', false)
}

// if selected keyword is in entry, the entries dom wlement will be set to visible
for (var i = 0; i < allKeywordElements.length; i++) {
if (allKeywordElements.item(i).name.toLowerCase() == this_keyword) { // looks for keyword in entire entry. could be more precise in looking at keyword
allKeywordElements.item(i).parentElement.setAttribute('style', 'display: normal;')//setAttribute('style', 'diplay: normal;')
allKeywordElements.item(i).setAttribute('selected', true) //setAttribute('selected', true)
console.log('set selected attribute of current keyword to true:', allKeywordElements.item(i).getAttribute('selected'))
allKeywordElements.item(i).parentElement.setAttribute('style', 'display: normal;')
allKeywordElements.item(i).setAttribute('selected', true)
}
}
}
Expand Down

0 comments on commit cbfa429

Please sign in to comment.