From 714d537624063d813475ba71637731a5939715c7 Mon Sep 17 00:00:00 2001
From: Stefan Peters
Date: Thu, 3 Mar 2022 09:48:40 +0100
Subject: [PATCH] ConceptSchemeSelection: Add filter for schemes with concepts
(#670)
---
config/locale.json | 2 ++
src/components/ConceptSchemeSelection.vue | 32 +++++++++++++++++++++--
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/config/locale.json b/config/locale.json
index 010afc1f..d01c9607 100644
--- a/config/locale.json
+++ b/config/locale.json
@@ -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",
@@ -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",
diff --git a/src/components/ConceptSchemeSelection.vue b/src/components/ConceptSchemeSelection.vue
index 840c59d6..6c38a06a 100644
--- a/src/components/ConceptSchemeSelection.vue
+++ b/src/components/ConceptSchemeSelection.vue
@@ -123,7 +123,7 @@
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") }}
@@ -133,6 +133,11 @@
size="sm">
{{ $t("schemeSelection.filterOnlyFavorites") }}
+
+ {{ $t("schemeSelection.filterOnlyWithConcepts") }}
+
schemes.find(scheme => this.$jskos.compareFast(registry, scheme._registry)))
@@ -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()
@@ -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")
@@ -616,6 +638,9 @@ export default {
) &&
(
!this.onlyFavorites || this.$jskos.isContainedIn(scheme, this.favoriteSchemes)
+ ) &&
+ (
+ !this.onlyWithConcepts || this.hasConcepts(scheme)
),
)
}
@@ -680,6 +705,9 @@ export default {
this.showPopover()
}
},
+ hasConcepts(scheme) {
+ return !scheme.concepts || scheme.concepts.length
+ },
},
}