Skip to content

Commit

Permalink
Fix/issue filter buckets wording and collection item display in filte…
Browse files Browse the repository at this point in the history
…rs (#1310)

* fix #1255: better translate item type

* fix #1210: add distinction between article count and matching results

* better highlight numbers with semi bold font
  • Loading branch information
danieleguido authored Sep 30, 2024
1 parent de941c0 commit a0abb8e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/components/modules/FilterFacet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export default defineComponent({
items: filter.items.map(item => {
if (this.bucketsIndex[item.uid]) {
return {
...this.bucketsIndex[item.uid].item,
...item,
count: this.bucketsIndex[item.uid].count
}
Expand Down Expand Up @@ -243,7 +244,7 @@ export default defineComponent({
bucketsIndex() {
const index = {}
this.facet.buckets.forEach(({ item, count }) => {
index[item.uid] = { count }
index[item.uid] = { count, item }
})
return index
},
Expand Down
54 changes: 36 additions & 18 deletions src/components/modules/FilterFacetBucket.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
<template>
<div class="FilterFacetBucket d-flex text-small">
<b-form-checkbox v-model="isChecked" data-testid="filter-facet-bucket-checkbox"> </b-form-checkbox>
<b-form-checkbox v-model="isChecked" data-testid="filter-facet-bucket-checkbox">
</b-form-checkbox>

<item-selector hide-icon :uid="bucket.val" :item="bucket.item" :type="type" :searchIndex="searchIndex">
<item-selector
hide-icon
:uid="bucket.val"
:item="bucket.item"
:type="type"
:searchIndex="searchIndex"
>
<item-label v-if="bucket.item" :item="bucket.item" :type="type" />
<span class="FilterFacetBucket__label" v-else>{{ item }}</span>
<span v-if="bucket.count > -1">
(<span v-html="$tc('numbers.results', bucket.count, { n: $n(bucket.count) })" />)
(<span
v-html="
$tc(
type === 'collection' ? 'numbers.articlesMatchingSearchFilters' : 'numbers.results',
bucket.count,
{ n: $n(bucket.count) }
)
"
/>
{{ type }})
</span>
</item-selector>
</div>
Expand All @@ -21,23 +37,23 @@ export default {
data: () => ({
operators: ['or', 'and', 'not'],
operator: 'or',
checked: false,
checked: false
}),
props: {
bucket: {
type: Object,
type: Object
},
type: {
type: String,
type: String
},
isLoadingResults: {
type: Boolean,
default: true,
default: true
},
searchIndex: {
type: String,
default: 'search',
},
default: 'search'
}
},
computed: {
isChecked: {
Expand All @@ -46,27 +62,27 @@ export default {
},
set(checked) {
this.checked = checked
this.bucket.checked = checked // eslint-disable-line
this.bucket.operator = this.operator // eslint-disable-line
this.bucket.checked = checked // eslint-disable-line
this.bucket.operator = this.operator // eslint-disable-line
this.$emit('toggle-bucket', this.bucket)
},
}
},
selectedOperator() {
return this.$t(`operator.${this.operator}`)
},
}
},
methods: {
selectOperator(operator) {
this.operator = operator
},
}
},
components: {
ItemSelector,
ItemLabel,
ItemLabel
},
mounted() {
this.checked = !!this.bucket.checked
},
}
}
</script>

Expand All @@ -85,7 +101,8 @@ export default {
}
</style>

<i18n lang="json">{
<i18n lang="json">
{
"en": {
"dates": {
"lastModifiedDate": "Last-Modified-Date"
Expand All @@ -96,4 +113,5 @@ export default {
"and": "include (AND)"
}
}
}</i18n>
}
</i18n>
10 changes: 9 additions & 1 deletion src/components/modules/FilterMonitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@
<span v-if="!item.uid">...</span>
<span v-if="item.count"
>&nbsp;(<span
v-html="$tc('numbers.results', item.count, { n: $n(item.count) })"
v-html="
$tc(
type === 'collection'
? 'numbers.articlesMatchingSearchFilters'
: 'numbers.results',
item.count,
{ n: $n(item.count) }
)
"
/>)&nbsp;</span
>
</item-selector>
Expand Down
14 changes: 7 additions & 7 deletions src/i18n/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default {
ob: 'obituary',
tb: 'tables',
section: 'section',
uc: 'unclassified content',
page: 'No article segmentation',
uc: 'unclassified items',
page: 'no article segmentation',
death_notice: 'obituary (other)',
weather: 'weather forecast',
w: 'weather news (other)',
Expand Down Expand Up @@ -283,13 +283,13 @@ export default {
optionsDescription: 'Total number of articles per day'
},
type: {
title: 'Article content type | Article content types | Article content types',
title: 'Item type | Item types | Item types',
optionsTitle: 'Article content type',
filterTitle: 'article type',
filterTitle: 'item types',
filtered: 'results are filtered when:',
selected: 'filter results if <b>one of {count} selected</b> article types applies',
description: 'check one or more article types to filter results',
empty: 'No articles types available',
selected: 'filter results if the item type is <b>one of {count} selected</b>',
description: 'check one or more item types to filter results',
empty: 'No item types available',
context: {
include: 'tagged as',
exclude: '<b>NOT</b> tagged as'
Expand Down
7 changes: 7 additions & 0 deletions src/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ h6.dropdown-header {
font-variation-settings: 'wght' 450;
}

b {
font-weight: var(--impresso-wght-bold);
font-variation-settings: 'wght' var(--impresso-wght-bold);
}
span.number {
font-variation-settings: 'wght' var(--impresso-wght-smallcaps);
}
label {
font-variant: normal;
font-family: var(--bs-font-sans-serif);
Expand Down

0 comments on commit a0abb8e

Please sign in to comment.