From ffeecd86cf6640a2a2384f2dd8cbf39e717e9520 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 13 Dec 2023 00:52:18 +0100 Subject: enh(UnifiedSearch): Keep the searchbar on top of the modal Signed-off-by: Ferdinand Thiessen --- core/src/views/UnifiedSearchModal.vue | 268 ++++++++++++++++++---------------- 1 file changed, 140 insertions(+), 128 deletions(-) (limited to 'core/src') diff --git a/core/src/views/UnifiedSearchModal.vue b/core/src/views/UnifiedSearchModal.vue index 59afa04d0ab..004005b57d9 100644 --- a/core/src/views/UnifiedSearchModal.vue +++ b/core/src/views/UnifiedSearchModal.vue @@ -10,79 +10,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') }} + + +
+
+ + + +
@@ -91,8 +101,8 @@
-
-
+
+
{{ providerResult.provider }}
@@ -115,14 +125,6 @@
-
- - {{ t('core', 'Filter in current view') }} - - -
@@ -149,6 +151,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 { @@ -179,6 +182,15 @@ export default { required: true, }, }, + setup() { + /** + * Reactive version of window.location + */ + const currentLocation = useBrowserLocation() + return { + currentLocation, + } + }, data() { return { providers: [], @@ -205,22 +217,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: { @@ -522,21 +534,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 - }, }, } -- cgit v1.2.3