From b46af101678114a61ff1e93c2015eb80e24dc823 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 13 Dec 2023 00:52:18 +0100 Subject: [PATCH] enh(UnifiedSearch): Keep the searchbar on top of the modal Signed-off-by: Ferdinand Thiessen [skip ci] --- core/src/views/UnifiedSearchModal.vue | 268 ++++++++++++++------------ 1 file changed, 140 insertions(+), 128 deletions(-) diff --git a/core/src/views/UnifiedSearchModal.vue b/core/src/views/UnifiedSearchModal.vue index 8d2d282049583..b724b31d28d4e 100644 --- a/core/src/views/UnifiedSearchModal.vue +++ b/core/src/views/UnifiedSearchModal.vue @@ -11,79 +11,89 @@ @update:is-open="showDateRangeModal = $event" />
-

{{ t('core', 'Unified search') }}

- -
- - - +
+

{{ t('core', 'Unified search') }}

+ +
+ - {{ t('core', provider.name) }} - - - - - - {{ t('core', 'Today') }} - - - {{ t('core', 'Last 7 days') }} - - - {{ t('core', 'Last 30 days') }} - - - {{ t('core', 'This year') }} - - - {{ t('core', 'Last year') }} - - - {{ t('core', 'Custom date range') }} - - - - - -
-
- - - + {{ provider.name }} + + + + + + {{ t('core', 'Today') }} + + + {{ t('core', 'Last 7 days') }} + + + {{ t('core', 'Last 30 days') }} + + + {{ t('core', 'This year') }} + + + {{ t('core', 'Last year') }} + + + {{ t('core', 'Custom date range') }} + + + + + + + {{ t('core', 'Filter in current view') }} + + +
+
+ + + +
@@ -92,8 +102,8 @@
-
-
+
+
{{ providerResult.provider }}
@@ -116,14 +126,6 @@
-
- - {{ t('core', 'Filter in current view') }} - - -
@@ -150,6 +152,7 @@ import SearchResult from '../components/UnifiedSearch/SearchResult.vue' import debounce from 'debounce' import { emit } from '@nextcloud/event-bus' +import { useBrowserLocation } from '@vueuse/core' import { getProviders, search as unifiedSearch, getContacts } from '../services/UnifiedSearchService.js' export default { @@ -180,6 +183,15 @@ export default { required: true, }, }, + setup() { + /** + * Reactive version of window.location + */ + const currentLocation = useBrowserLocation() + return { + currentLocation, + } + }, data() { return { providers: [], @@ -206,22 +218,22 @@ export default { }, computed: { - userContacts: { - get() { - return this.contacts - }, + userContacts() { + return this.contacts }, - noContentInfo: { - get() { - const isEmptySearch = this.searchQuery.length === 0 - const hasNoResults = this.searchQuery.length > 0 && this.results.length === 0 - - return { - show: isEmptySearch || hasNoResults, - text: this.searching && hasNoResults ? t('core', 'Searching …') : (isEmptySearch ? t('core', 'Start typing to search') : t('core', 'No matching results')), - icon: MagnifyIcon, - } - }, + noContentInfo() { + const isEmptySearch = this.searchQuery.length === 0 + const hasNoResults = this.searchQuery.length > 0 && this.results.length === 0 + return { + show: isEmptySearch || hasNoResults, + text: this.searching && hasNoResults ? t('core', 'Searching …') : (isEmptySearch ? t('core', 'Start typing to search') : t('core', 'No matching results')), + icon: MagnifyIcon, + } + }, + supportFiltering() { + /* Hard coded apps for the moment this would be improved in coming updates. */ + const providerPaths = ['/settings/users', '/apps/files', '/apps/deck'] + return providerPaths.some((path) => this.currentLocation.pathname?.includes?.(path)) }, }, watch: { @@ -523,21 +535,27 @@ export default { this.internalIsVisible = false this.searchQuery = '' }, - supportFiltering() { - /* Hard coded apps for the moment this would be improved in coming updates. */ - const providerPaths = ['/settings/users', '/apps/files', '/apps/deck'] - const currentPath = window.location.pathname.replace('/index.php', '') - const containsProvider = providerPaths.some(path => currentPath.includes(path)) - return containsProvider - }, }, }