Skip to content

Commit

Permalink
Fix typescript error when vocabs are undefined, so that mocha tests work
Browse files Browse the repository at this point in the history
(cherry picked from commit 8cbf9e5)
  • Loading branch information
rogup committed Mar 12, 2024
1 parent e71c808 commit 76648ff
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions src/map-app/app/view/sidebar/initiatives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,32 +177,34 @@ export class InitiativesSidebarView extends BaseSidebarView {
.attr("class", "advanced-option")


const vocab = vocabs.getVocab(uri, lang);
const entryArray = Object.entries(vocab.terms);
// Sort entries alphabetically by value (the human-readable labels)
entryArray.sort((a, b) => String(a[1]).localeCompare(String(b[1])));


const alternatePossibleFilterValues = mapui.getAlternatePossibleFilterValues(propName);
const filters = mapui.currentItem().propFilters;
const filter = filters[propName];

entryArray.forEach(entry => {
const [value, label] = entry;
const option = dropDown
.append("option")
.text(label ?? '')
.attr("value", value)
.attr("class", "advanced-option")

// if there are active filters, label the one currently selected and disable empty choices
if (filter && filter.valueRequired === value) {
option.attr("selected", true);
}
if (!alternatePossibleFilterValues.has(value)) {
option.attr("disabled", true);
}
})
if (vocabs !== undefined) {
const vocab = vocabs.getVocab(uri, lang);
const entryArray = Object.entries(vocab.terms);
// Sort entries alphabetically by value (the human-readable labels)
entryArray.sort((a, b) => String(a[1]).localeCompare(String(b[1])));


const alternatePossibleFilterValues = mapui.getAlternatePossibleFilterValues(propName);
const filters = mapui.currentItem().propFilters;
const filter = filters[propName];

entryArray.forEach(entry => {
const [value, label] = entry;
const option = dropDown
.append("option")
.text(label ?? '')
.attr("value", value)
.attr("class", "advanced-option")

// if there are active filters, label the one currently selected and disable empty choices
if (filter && filter.valueRequired === value) {
option.attr("selected", true);
}
if (!alternatePossibleFilterValues.has(value)) {
option.attr("disabled", true);
}
})
}
}
}

Expand Down

0 comments on commit 76648ff

Please sign in to comment.