Skip to content

Commit

Permalink
ConceptSchemeSelection: Add filter for schemes with concepts (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Mar 3, 2022
1 parent d8969b4 commit 714d537
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"filterSelectAll": "select all",
"filterDeselectAll": "deselect all",
"filterOnlyFavorites": "Show only favorites",
"filterOnlyWithConcepts": "Show only schemes with concepts",
"languageFilter": "Language",
"typeFilter": "Scheme Type",
"filterOther": "Other",
Expand Down Expand Up @@ -381,6 +382,7 @@
"filterSelectAll": "alle auswählen",
"filterDeselectAll": "alle abwählen",
"filterOnlyFavorites": "Nur Favoriten anzeigen",
"filterOnlyWithConcepts": "Nur Vokabulare mit Konzepten anzeigen",
"languageFilter": "Sprache",
"typeFilter": "Vokabular-Typ",
"filterOther": "Sonstige",
Expand Down
32 changes: 30 additions & 2 deletions src/components/ConceptSchemeSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<a
ref="removeAllFiltersLink"
href=""
@click.prevent="onlyFavorites = false; schemeFilter = ''; registryFilter = availableRegistries.map(r => r.uri); languageFilter = availableLanguages.concat([null]); typeFilter = availableTypes.concat([null]);">
@click.prevent="onlyFavorites = false; onlyWithConcepts = false; schemeFilter = ''; registryFilter = availableRegistries.map(r => r.uri); languageFilter = availableLanguages.concat([null]); typeFilter = availableTypes.concat([null]);">
{{ $t("schemeSelection.filtersRemove") }}
</a>
</p>
Expand All @@ -133,6 +133,11 @@
size="sm">
{{ $t("schemeSelection.filterOnlyFavorites") }}
</b-form-checkbox>
<b-form-checkbox
v-model="onlyWithConcepts"
size="sm">
{{ $t("schemeSelection.filterOnlyWithConcepts") }}
</b-form-checkbox>
<!-- Registry filter -->
<div
v-b-toggle="`conceptSchemeSelection-filterPopover-${id}-registryFilterCollapse`"
Expand Down Expand Up @@ -323,6 +328,8 @@ export default {
typeFilter: [],
// Flag whether to show only favorite concepts
onlyFavorites: true,
// Flag whether to show only schemes that potentially have concepts
onlyWithConcepts: false,
// Item component for VirtualList
itemComponent: ConceptSchemeSelectionItemVue,
// TODO: To mitigate performance issues, we're updating these properties in a debounced watcher.
Expand All @@ -347,7 +354,7 @@ export default {
},
// Indicates whether there is a filter active.
isFiltered() {
return this.schemeFilter != "" || this.registryFilter.length < this.availableRegistries.length || (this.languageFilter.length - 1) < this.availableLanguages.length || (this.typeFilter.length - 1) < this.availableTypes.length || this.onlyFavorites
return this.schemeFilter != "" || this.registryFilter.length < this.availableRegistries.length || (this.languageFilter.length - 1) < this.availableLanguages.length || (this.typeFilter.length - 1) < this.availableTypes.length || this.onlyFavorites || this.onlyWithConcepts
},
// Returns an array of all available registries
availableRegistries() {
Expand Down Expand Up @@ -427,6 +434,12 @@ export default {
this.schemeFilter = ""
this.updateProperties()
},
onlyWithConcepts(value) {
if (value) {
this.onlyFavorites = false
}
this.updateProperties()
},
favoriteSchemes() {
this.updateProperties()
},
Expand Down Expand Up @@ -521,6 +534,9 @@ export default {
) &&
(
!this.onlyFavorites || this.$jskos.isContainedIn(scheme, this.favoriteSchemes)
) &&
(
!this.onlyWithConcepts || this.hasConcepts(scheme)
),
)
this.shownRegistries = this.availableRegistries.filter(registry => schemes.find(scheme => this.$jskos.compareFast(registry, scheme._registry)))
Expand All @@ -538,6 +554,9 @@ export default {
) &&
(
!this.onlyFavorites || this.$jskos.isContainedIn(scheme, this.favoriteSchemes)
) &&
(
!this.onlyWithConcepts || this.hasConcepts(scheme)
),
)
this.shownLanguages = _.uniq([].concat(...schemes.map(scheme => scheme.languages || []))).sort()
Expand All @@ -555,6 +574,9 @@ export default {
) &&
(
!this.onlyFavorites || this.$jskos.isContainedIn(scheme, this.favoriteSchemes)
) &&
(
!this.onlyWithConcepts || this.hasConcepts(scheme)
),
)
this.shownTypes = _.uniq(_.flatten(schemes.map(scheme => scheme.type || []))).filter(type => type && type != "http://www.w3.org/2004/02/skos/core#ConceptScheme")
Expand Down Expand Up @@ -616,6 +638,9 @@ export default {
) &&
(
!this.onlyFavorites || this.$jskos.isContainedIn(scheme, this.favoriteSchemes)
) &&
(
!this.onlyWithConcepts || this.hasConcepts(scheme)
),
)
}
Expand Down Expand Up @@ -680,6 +705,9 @@ export default {
this.showPopover()
}
},
hasConcepts(scheme) {
return !scheme.concepts || scheme.concepts.length
},
},
}
</script>
Expand Down

0 comments on commit 714d537

Please sign in to comment.