diff options
author | nfebe <fenn25.fn@gmail.com> | 2025-01-10 14:20:55 +0100 |
---|---|---|
committer | nfebe <fenn25.fn@gmail.com> | 2025-01-20 19:58:32 +0100 |
commit | 6165fe7853b35f5fc914136fc18687a567ef99a2 (patch) | |
tree | 913a8ddc8873414b8dd6fbd4e76c29494e00655a | |
parent | 994ffe109fab9beb46df0628968907760fd2b682 (diff) | |
download | nextcloud-server-backport/50128/stable29.tar.gz nextcloud-server-backport/50128/stable29.zip |
feat: Adapt providers `disabled` property to match user applied filtersbackport/50128/stable29
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>
-rw-r--r-- | core/src/views/UnifiedSearchModal.vue | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/core/src/views/UnifiedSearchModal.vue b/core/src/views/UnifiedSearchModal.vue index 7ee56ecb3bb..0d85ed491f6 100644 --- a/core/src/views/UnifiedSearchModal.vue +++ b/core/src/views/UnifiedSearchModal.vue @@ -27,6 +27,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=""> @@ -299,22 +300,18 @@ export default { 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 } } @@ -415,6 +412,10 @@ export default { 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) console.debug('Person filter applied', person) }, @@ -471,6 +472,7 @@ export default { if (filter.type === 'person') { this.personFilterIsApplied = false } + this.enableAllProviders() break } } @@ -509,6 +511,9 @@ export default { 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) { @@ -599,6 +604,14 @@ export default { 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 + }) + }, focusInput() { this.$refs.searchInput.$el.children[0].children[0].focus() }, |