Skip to content

Commit

Permalink
fix: entity filter dropdown for unknown project (resolve #621) [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Mar 12, 2024
1 parent 80dc552 commit cd0449a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions static/assets/js/components/entity-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ function EntityFilter({type, options, selection}) {
this.selection = e.target.value == 'null' ? null : e.target.value
this.$nextTick(() => {
const query = new URLSearchParams(window.location.search)
if (this.selection) query.set(type, this.selection)
const val = this.selection === 'unknown' ? '-' : this.selection // will break if the project is actually named "unknown"
if (this.selection) query.set(type, val)
else query.delete(type)
window.location.search = query.toString()
})
},
mounted() {
const query = new URLSearchParams(window.location.search)
if (query.has(type)) {
const val = query.get(type)
const val = query.get(type) === '-' ? 'unknown' : query.get(type)
if (!this.options.includes(val)) {
this.options = [val, ...this.options]
}
Expand Down
2 changes: 1 addition & 1 deletion static/assets/js/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function draw(subselection) {
onClick: (event, data) => {
const url = new URL(window.location.href)
const name = wakapiData.projects[data[0].index].key
url.searchParams.set('project', name === 'unknown' ? '-' : name)
url.searchParams.set('project', name === 'unknown' ? '-' : name) // will break if the project is actually named "unknown"
window.location.href = url.href
},
onHover: (event, elem) => {
Expand Down

0 comments on commit cd0449a

Please sign in to comment.