|
27 | 27 | provider.id concatenated to provider.name is used to create the item id, if same then, there should be an issue. --> |
28 | 28 | <NcActionButton v-for="provider in providers" |
29 | 29 | :key="`${provider.id}-${provider.name.replace(/\s/g, '')}`" |
| 30 | + :disabled="provider.disabled" |
30 | 31 | @click="addProviderFilter(provider)"> |
31 | 32 | <template #icon> |
32 | 33 | <img :src="provider.icon" class="filter-button__icon" alt=""> |
@@ -299,22 +300,18 @@ export default { |
299 | 300 | extraQueries: provider.extraParams, |
300 | 301 | } |
301 | 302 |
|
| 303 | + // This block of filter checks should be dynamic somehow and should be handled in |
| 304 | + // nextcloud/search lib |
302 | 305 | if (filters.dateFilterIsApplied) { |
303 | 306 | if (provider.filters.since && provider.filters.until) { |
304 | 307 | params.since = this.dateFilter.startFrom |
305 | 308 | params.until = this.dateFilter.endAt |
306 | | - } else { |
307 | | - // Date filter is applied but provider does not support it, no need to search provider |
308 | | - return |
309 | 309 | } |
310 | 310 | } |
311 | 311 |
|
312 | 312 | if (filters.personFilterIsApplied) { |
313 | 313 | if (provider.filters.person) { |
314 | 314 | params.person = this.personFilter.user |
315 | | - } else { |
316 | | - // Person filter is applied but provider does not support it, no need to search provider |
317 | | - return |
318 | 315 | } |
319 | 316 | } |
320 | 317 |
|
@@ -415,6 +412,10 @@ export default { |
415 | 412 | this.filters[existingPersonFilter].name = person.displayName |
416 | 413 | } |
417 | 414 |
|
| 415 | + this.providers.forEach(async (provider, index) => { |
| 416 | + this.providers[index].disabled = !(await this.providerIsCompatibleWithFilters(provider, ['person'])) |
| 417 | + }) |
| 418 | +
|
418 | 419 | this.debouncedFind(this.searchQuery) |
419 | 420 | console.debug('Person filter applied', person) |
420 | 421 | }, |
@@ -471,6 +472,7 @@ export default { |
471 | 472 | if (filter.type === 'person') { |
472 | 473 | this.personFilterIsApplied = false |
473 | 474 | } |
| 475 | + this.enableAllProviders() |
474 | 476 | break |
475 | 477 | } |
476 | 478 | } |
@@ -509,6 +511,9 @@ export default { |
509 | 511 | this.filters.push(this.dateFilter) |
510 | 512 | } |
511 | 513 | this.dateFilterIsApplied = true |
| 514 | + this.providers.forEach(async (provider, index) => { |
| 515 | + this.providers[index].disabled = !(await this.providerIsCompatibleWithFilters(provider, ['since', 'until'])) |
| 516 | + }) |
512 | 517 | this.debouncedFind(this.searchQuery) |
513 | 518 | }, |
514 | 519 | applyQuickDateRange(range) { |
@@ -599,6 +604,14 @@ export default { |
599 | 604 |
|
600 | 605 | return flattenedArray |
601 | 606 | }, |
| 607 | + async providerIsCompatibleWithFilters(provider, filterIds) { |
| 608 | + return filterIds.every(filterId => provider.filters?.[filterId] !== undefined) |
| 609 | + }, |
| 610 | + async enableAllProviders() { |
| 611 | + this.providers.forEach(async (_, index) => { |
| 612 | + this.providers[index].disabled = false |
| 613 | + }) |
| 614 | + }, |
602 | 615 | focusInput() { |
603 | 616 | this.$refs.searchInput.$el.children[0].children[0].focus() |
604 | 617 | }, |
|
0 commit comments