|
34 | 34 | provider.id concatenated to provider.name is used to create the item id, if same then, there should be an issue. --> |
35 | 35 | <NcActionButton v-for="provider in providers" |
36 | 36 | :key="`${provider.id}-${provider.name.replace(/\s/g, '')}`" |
| 37 | + :disabled="provider.disabled" |
37 | 38 | @click="addProviderFilter(provider)"> |
38 | 39 | <template #icon> |
39 | 40 | <img :src="provider.icon" class="filter-button__icon" alt=""> |
@@ -378,22 +379,18 @@ export default defineComponent({ |
378 | 379 | extraQueries: provider.extraParams, |
379 | 380 | } |
380 | 381 |
|
| 382 | + // This block of filter checks should be dynamic somehow and should be handled in |
| 383 | + // nextcloud/search lib |
381 | 384 | if (filters.dateFilterIsApplied) { |
382 | 385 | if (provider.filters?.since && provider.filters?.until) { |
383 | 386 | params.since = this.dateFilter.startFrom |
384 | 387 | params.until = this.dateFilter.endAt |
385 | | - } else { |
386 | | - // Date filter is applied but provider does not support it, no need to search provider |
387 | | - return |
388 | 388 | } |
389 | 389 | } |
390 | 390 |
|
391 | 391 | if (filters.personFilterIsApplied) { |
392 | 392 | if (provider.filters?.person) { |
393 | 393 | params.person = this.personFilter.user |
394 | | - } else { |
395 | | - // Person filter is applied but provider does not support it, no need to search provider |
396 | | - return |
397 | 394 | } |
398 | 395 | } |
399 | 396 |
|
@@ -493,6 +490,10 @@ export default defineComponent({ |
493 | 490 | this.filters[existingPersonFilter].name = person.displayName |
494 | 491 | } |
495 | 492 |
|
| 493 | + this.providers.forEach(async (provider, index) => { |
| 494 | + this.providers[index].disabled = !(await this.providerIsCompatibleWithFilters(provider, ['person'])) |
| 495 | + }) |
| 496 | +
|
496 | 497 | this.debouncedFind(this.searchQuery) |
497 | 498 | unifiedSearchLogger.debug('Person filter applied', { person }) |
498 | 499 | }, |
@@ -549,6 +550,7 @@ export default defineComponent({ |
549 | 550 | if (filter.type === 'person') { |
550 | 551 | this.personFilterIsApplied = false |
551 | 552 | } |
| 553 | + this.enableAllProviders() |
552 | 554 | break |
553 | 555 | } |
554 | 556 | } |
@@ -587,6 +589,9 @@ export default defineComponent({ |
587 | 589 | this.filters.push(this.dateFilter) |
588 | 590 | } |
589 | 591 | this.dateFilterIsApplied = true |
| 592 | + this.providers.forEach(async (provider, index) => { |
| 593 | + this.providers[index].disabled = !(await this.providerIsCompatibleWithFilters(provider, ['since', 'until'])) |
| 594 | + }) |
590 | 595 | this.debouncedFind(this.searchQuery) |
591 | 596 | }, |
592 | 597 | applyQuickDateRange(range) { |
@@ -677,6 +682,14 @@ export default defineComponent({ |
677 | 682 |
|
678 | 683 | return flattenedArray |
679 | 684 | }, |
| 685 | + async providerIsCompatibleWithFilters(provider, filterIds) { |
| 686 | + return filterIds.every(filterId => provider.filters?.[filterId] !== undefined) |
| 687 | + }, |
| 688 | + async enableAllProviders() { |
| 689 | + this.providers.forEach(async (_, index) => { |
| 690 | + this.providers[index].disabled = false |
| 691 | + }) |
| 692 | + }, |
680 | 693 | }, |
681 | 694 | }) |
682 | 695 | </script> |
|
0 commit comments