Skip to content

Commit

Permalink
Alphabetize sidebar filter options
Browse files Browse the repository at this point in the history
  • Loading branch information
lydiascarf committed Jun 14, 2024
1 parent 16b0cb4 commit bb4499d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scripts/dist/bundle.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion scripts/src/components/categories-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import {setContent, slugify, createDatasetFilters, collapseListGroup} from '../u
export default class {
constructor (opts) {
const categories = this._categoriesWithCount(opts.datasets, opts.params)
const categoriesMarkup = categories.map(TmplListGroupItem)
const categoriesMarkup = categories.sort((a,b) => {
// ignore upper and lowercase
const titleA = a.title.toUpperCase();
const titleB = b.title.toUpperCase();
if (titleA < titleB) return -1;
if (titleA > titleB) return 1;
return 0;
}).map(TmplListGroupItem)
setContent(opts.el, categoriesMarkup)
collapseListGroup(opts.el)
}
Expand Down
9 changes: 8 additions & 1 deletion scripts/src/components/rdl-country-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ export default class {
}
})

const countriesMarkup = consolidated.map(TmplListGroupItem)
const countriesMarkup = consolidated.sort((a,b) => {
// ignore upper and lowercase
const titleA = a.title.toUpperCase();
const titleB = b.title.toUpperCase();
if (titleA < titleB) return -1;
if (titleA > titleB) return 1;
return 0;
}).map(TmplListGroupItem)
setContent(opts.el, countriesMarkup)
collapseListGroup(opts.el)
}
Expand Down
9 changes: 8 additions & 1 deletion scripts/src/components/rdl-geographical-scale-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ export default class {
}
})

const geographicalScalesMarkup = consolidated.map(TmplListGroupItem)
const geographicalScalesMarkup = consolidated.sort((a,b) => {
// ignore upper and lowercase
const titleA = a.title.toUpperCase();
const titleB = b.title.toUpperCase();
if (titleA < titleB) return -1;
if (titleA > titleB) return 1;
return 0;
}).map(TmplListGroupItem)
setContent(opts.el, geographicalScalesMarkup)
collapseListGroup(opts.el)
}
Expand Down
9 changes: 8 additions & 1 deletion scripts/src/components/rdl-license-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ export default class {
}
})

const licensesMarkup = consolidated.map(TmplListGroupItem)
const licensesMarkup = consolidated.sort((a,b) => {
// ignore upper and lowercase
const titleA = a.title.toUpperCase();
const titleB = b.title.toUpperCase();
if (titleA < titleB) return -1;
if (titleA > titleB) return 1;
return 0;
}).map(TmplListGroupItem)
setContent(opts.el, licensesMarkup)
collapseListGroup(opts.el)
}
Expand Down

0 comments on commit bb4499d

Please sign in to comment.