Skip to content

Commit

Permalink
Fix sorting on geo scale
Browse files Browse the repository at this point in the history
Should go Global, Regional, National, Sub-national
  • Loading branch information
lydiascarf committed Jun 14, 2024
1 parent 94abca7 commit cb3c991
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/dist/bundle.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion scripts/src/components/rdl-geographical-scale-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import {chain, omit, defaults} from 'lodash'
import TmplListGroupItem from '../templates/list-group-item'
import {setContent, slugify, collapseListGroup} from '../util'

const ORDER = [
'Global',
'Regional',
'National',
'Sub-national',
]

function prep_geographical_scale(geographicalScale, params, datasetsForGeographicalScales) {
const geographicalScaleSlug = slugify(geographicalScale)
Expand Down Expand Up @@ -32,7 +38,11 @@ export default class {
}
})

const geographicalScalesMarkup = consolidated.map(TmplListGroupItem)
const geographicalScalesMarkup = consolidated.sort((a,b) => {
const aIndex = ORDER.findIndex((title) => title === a.title);
const bIndex = ORDER.findIndex((title) => title === b.title);
return aIndex - bIndex;
}).map(TmplListGroupItem)
setContent(opts.el, geographicalScalesMarkup)
collapseListGroup(opts.el)
}
Expand Down

0 comments on commit cb3c991

Please sign in to comment.