Skip to content

Commit

Permalink
adds alphabetical filter to legislation listing
Browse files Browse the repository at this point in the history
  • Loading branch information
actlikewill committed May 23, 2024
1 parent 0c88843 commit f3bf538
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion peachjam/js/components/LegislationTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
<div v-if="false">
{{ $t('Years') }}
{{ $t('Taxonomies') }}
{{ $t('Alphabetical') }}
</div>
</div>
</template>
Expand Down Expand Up @@ -310,8 +311,18 @@ export default {
taxonomyOptions.sort((a, b) => a.value.localeCompare(b.value));
// Sort descending
yearsOptions.sort((a, b) => b.value - a.value);
const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('').map(letter => ({
label: letter.toUpperCase(),
value: letter
}));
this.facets = [
{
title: this.$t('Alphabetical'),
name: 'alphabetical',
type: 'letter-radio',
value: [],
options: alphabet
},
{
title: this.$t('Years'),
name: 'year',
Expand Down Expand Up @@ -367,6 +378,9 @@ export default {
});
Object.keys(facetDict).forEach((key) => {
data = data.filter((item) => {
if (key === 'alphabetical') {
return item.title.toLowerCase().startsWith(facetDict[key]);
}
if (Array.isArray(facetDict[key])) {
const arr1 = facetDict[key].map((x) => String(x));
const arr2 = item[key].map((x) => String(x));
Expand Down

0 comments on commit f3bf538

Please sign in to comment.