-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter bugfixes #848
Filter bugfixes #848
Changes from 3 commits
b0a3ccc
1b42811
34c360d
a804399
a3ab289
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -88,8 +88,13 @@ class Filters { | |||||
techSelector.before(errorMsg); | ||||||
} | ||||||
|
||||||
/* Get a list of technologies */ | ||||||
const techs = this.technologies; | ||||||
const sortedTechs = techs.sort((a, b) => a.technology - b.technology); | ||||||
sortedTechs.unshift({ technology: 'ALL' }); | ||||||
|
||||||
/* Add one option per technology */ | ||||||
this.technologies.forEach((technology) => { | ||||||
sortedTechs.forEach((technology) => { | ||||||
const optionTmpl = document.getElementById('filter-option').content.cloneNode(true); | ||||||
const option = optionTmpl.querySelector('option'); | ||||||
const formattedTech = technology.technology; | ||||||
|
@@ -107,7 +112,8 @@ class Filters { | |||||
updateGeo() { | ||||||
const select = document.querySelector('select#geo'); | ||||||
select.innerHTML = ''; | ||||||
this.geos.forEach((geo) => { | ||||||
const sortedGeos = this.geos.sort((a, b) => a.geo !== b.geo ? a.geo < b.geo ? -1 : 1 : 0); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per #845 (comment) let's revert back to sorting by # sites There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See: #848 (comment) For geos I'm wondering if alphabetical might make it easier to find specific countries, as that's how most country selectors on the web are sorted alphabetically. If I want to find Norway, I know I still have to scroll further when I see "Finland" but am close when I see "Netherlands" or "North Korea". Maybe a good one to look for some more feedback/user tests on, or try out two different designs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
sortedGeos.forEach((geo) => { | ||||||
const optionTmpl = document.getElementById('filter-option').content.cloneNode(true); | ||||||
const option = optionTmpl.querySelector('option'); | ||||||
const formattedTech = geo.geo; | ||||||
|
@@ -150,7 +156,8 @@ class Filters { | |||||
all.innerHTML = 'ALL'; | ||||||
select.append(all); | ||||||
|
||||||
this.categories.forEach((category) => { | ||||||
const sortedCategories = this.categories.sort((a, b) => a.category !== b.category ? a.category < b.category ? -1 : 1 : 0); | ||||||
sortedCategories.forEach((category) => { | ||||||
const option = document.createElement('option'); | ||||||
option.value = category.category; | ||||||
option.innerHTML = category.category; | ||||||
|
@@ -162,18 +169,21 @@ class Filters { | |||||
|
||||||
/* Set the selected category */ | ||||||
updateCategory(event) { | ||||||
const selectedTechs = this.categories.find(category => category.category === event.target.value)?.technologies; | ||||||
const selectedTechInfo = []; | ||||||
selectedTechs.forEach(selectedTech => selectedTechInfo.push(this.technologies.find(tech => tech.technology === selectedTech))); | ||||||
// Get the techs associated with the selected category | ||||||
const selectedCategory = this.categories.find(category => category.category === event.target.value); | ||||||
const selectedTechs = selectedCategory?.technologies; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need a fallback in case
Suggested change
|
||||||
console.log(selectedCategory, selectedTechs); | ||||||
|
||||||
// Get the component with the selected tech | ||||||
const techSelector = document.getElementById(event.target.dataset.tech); | ||||||
techSelector.innerHTML = ''; | ||||||
|
||||||
selectedTechInfo.forEach((technology) => { | ||||||
// Update the options | ||||||
selectedTechs.forEach((technology) => { | ||||||
const option = document.createElement('option'); | ||||||
const formattedTech = technology.technology; | ||||||
option.textContent = technology.technology; | ||||||
option.value = formattedTech; | ||||||
if(formattedTech === techSelector.getAttribute('data-selected')) { | ||||||
option.textContent = technology; | ||||||
option.value = technology; | ||||||
if(technology === techSelector.getAttribute('data-selected')) { | ||||||
option.selected = true; | ||||||
} | ||||||
techSelector.append(option); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per #845 (comment) let's revert back to sorting by # sites
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just revert back for now, and suggest we add more user-friendly dropdowns as a separate action item (so deciding on a sort order and design for it doesn't block the other bugfixes in this PR). If we keep it by origins, then we should implement a component more similar to the old report, where we can display the numbers as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM!