aboutsummaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authornfebe <fenn25.fn@gmail.com>2025-01-10 14:20:55 +0100
committerF. E Noel Nfebe <fenn25.fn@gmail.com>2025-01-17 11:31:18 +0100
commitd2ea5d2a6122d8c09026d90aa4ab04f5ac8fabf4 (patch)
tree142a6639eaac441668ab4b45de7bc5839c67de7e /core/src
parent8bdaf80eadea5473dc18dd4a37738120475c2882 (diff)
downloadnextcloud-server-d2ea5d2a6122d8c09026d90aa4ab04f5ac8fabf4.tar.gz
nextcloud-server-d2ea5d2a6122d8c09026d90aa4ab04f5ac8fabf4.zip
feat: Adapt providers `disabled` property to match user applied filters
Some filters are only available for certain providers, the UI should give the user a hint to what providers such filters are available in. Currently, if a filter (date or person) is not support by an a provider, the provider is blurred out in the places dropdown. Signed-off-by: nfebe <fenn25.fn@gmail.com>
Diffstat (limited to 'core/src')
-rw-r--r--core/src/components/UnifiedSearch/UnifiedSearchModal.vue25
1 files changed, 19 insertions, 6 deletions
diff --git a/core/src/components/UnifiedSearch/UnifiedSearchModal.vue b/core/src/components/UnifiedSearch/UnifiedSearchModal.vue
index ef0883c5b25..7400956f96b 100644
--- a/core/src/components/UnifiedSearch/UnifiedSearchModal.vue
+++ b/core/src/components/UnifiedSearch/UnifiedSearchModal.vue
@@ -34,6 +34,7 @@
provider.id concatenated to provider.name is used to create the item id, if same then, there should be an issue. -->
<NcActionButton v-for="provider in providers"
:key="`${provider.id}-${provider.name.replace(/\s/g, '')}`"
+ :disabled="provider.disabled"
@click="addProviderFilter(provider)">
<template #icon>
<img :src="provider.icon" class="filter-button__icon" alt="">
@@ -378,22 +379,18 @@ export default defineComponent({
extraQueries: provider.extraParams,
}
+ // This block of filter checks should be dynamic somehow and should be handled in
+ // nextcloud/search lib
if (filters.dateFilterIsApplied) {
if (provider.filters?.since && provider.filters?.until) {
params.since = this.dateFilter.startFrom
params.until = this.dateFilter.endAt
- } else {
- // Date filter is applied but provider does not support it, no need to search provider
- return
}
}
if (filters.personFilterIsApplied) {
if (provider.filters?.person) {
params.person = this.personFilter.user
- } else {
- // Person filter is applied but provider does not support it, no need to search provider
- return
}
}
@@ -493,6 +490,10 @@ export default defineComponent({
this.filters[existingPersonFilter].name = person.displayName
}
+ this.providers.forEach(async (provider, index) => {
+ this.providers[index].disabled = !(await this.providerIsCompatibleWithFilters(provider, ['person']))
+ })
+
this.debouncedFind(this.searchQuery)
unifiedSearchLogger.debug('Person filter applied', { person })
},
@@ -549,6 +550,7 @@ export default defineComponent({
if (filter.type === 'person') {
this.personFilterIsApplied = false
}
+ this.enableAllProviders()
break
}
}
@@ -587,6 +589,9 @@ export default defineComponent({
this.filters.push(this.dateFilter)
}
this.dateFilterIsApplied = true
+ this.providers.forEach(async (provider, index) => {
+ this.providers[index].disabled = !(await this.providerIsCompatibleWithFilters(provider, ['since', 'until']))
+ })
this.debouncedFind(this.searchQuery)
},
applyQuickDateRange(range) {
@@ -677,6 +682,14 @@ export default defineComponent({
return flattenedArray
},
+ async providerIsCompatibleWithFilters(provider, filterIds) {
+ return filterIds.every(filterId => provider.filters?.[filterId] !== undefined)
+ },
+ async enableAllProviders() {
+ this.providers.forEach(async (_, index) => {
+ this.providers[index].disabled = false
+ })
+ },
},
})
</script>