diff options
author | F. E Noel Nfebe <fenn25.fn@gmail.com> | 2023-12-13 09:52:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-13 09:52:58 +0100 |
commit | 63babd23242ef9482ee33c61ae9f9080b72b7a8f (patch) | |
tree | bc488c662f070f4e2f923b6bb6df95de0b39b569 /core | |
parent | 895eb194497ebeb381ee6ebdc4274688f6a493fd (diff) | |
parent | 842953a267f406a159fc7982bac7c87365c24c81 (diff) | |
download | nextcloud-server-63babd23242ef9482ee33c61ae9f9080b72b7a8f.tar.gz nextcloud-server-63babd23242ef9482ee33c61ae9f9080b72b7a8f.zip |
Merge pull request #42167 from nextcloud/unified-search-improvements
Unified search improvements
Diffstat (limited to 'core')
-rw-r--r-- | core/src/components/UnifiedSearch/SearchableList.vue | 4 | ||||
-rw-r--r-- | core/src/services/UnifiedSearchService.js | 16 | ||||
-rw-r--r-- | core/src/views/UnifiedSearchModal.vue | 10 |
3 files changed, 26 insertions, 4 deletions
diff --git a/core/src/components/UnifiedSearch/SearchableList.vue b/core/src/components/UnifiedSearch/SearchableList.vue index 43f7ace1b64..33f45d06266 100644 --- a/core/src/components/UnifiedSearch/SearchableList.vue +++ b/core/src/components/UnifiedSearch/SearchableList.vue @@ -32,6 +32,7 @@ :label="labelText" trailing-button-icon="close" :show-trailing-button="searchTerm !== ''" + @update:value="searchTermChanged" @trailing-button-click="clearSearch"> <Magnify :size="20" /> </NcTextField> @@ -126,6 +127,9 @@ export default { this.clearSearch() this.opened = false }, + searchTermChanged(term) { + this.$emit('search-term-change', term) + }, }, } </script> diff --git a/core/src/services/UnifiedSearchService.js b/core/src/services/UnifiedSearchService.js index e477a59eb4c..fddbd6b1e1d 100644 --- a/core/src/services/UnifiedSearchService.js +++ b/core/src/services/UnifiedSearchService.js @@ -22,6 +22,7 @@ import { generateOcsUrl, generateUrl } from '@nextcloud/router' import axios from '@nextcloud/axios' +import { getCurrentUser } from '@nextcloud/auth' /** * Create a cancel token @@ -103,5 +104,20 @@ export async function getContacts({ searchTerm }) { const { data: { contacts } } = await axios.post(generateUrl('/contactsmenu/contacts'), { filter: searchTerm, }) + /* + * Add authenticated user to list of contacts for search filter + * If authtenicated user is searching/filtering, do not add them to the list + */ + if (!searchTerm) { + let authenticatedUser = getCurrentUser() + authenticatedUser = { + id: authenticatedUser.uid, + fullName: 'Me', + emailAddresses: [], + } + contacts.unshift(authenticatedUser) + return contacts + } + return contacts } diff --git a/core/src/views/UnifiedSearchModal.vue b/core/src/views/UnifiedSearchModal.vue index ca314fa2673..49a07136fe8 100644 --- a/core/src/views/UnifiedSearchModal.vue +++ b/core/src/views/UnifiedSearchModal.vue @@ -56,6 +56,7 @@ <SearchableList :label-text="t('core', 'Search people')" :search-list="userContacts" :empty-content-text="t('core', 'Not found')" + @search-term-change="debouncedFilterContacts" @item-selected="applyPersonFilter"> <template #trigger> <NcButton> @@ -193,12 +194,13 @@ export default { filteredProviders: [], searching: false, searchQuery: '', - placesFilter: '', + placessearchTerm: '', dateTimeFilter: null, filters: [], results: [], contacts: [], debouncedFind: debounce(this.find, 300), + debouncedFilterContacts: debounce(this.filterContacts, 300), showDateRangeModal: false, internalIsVisible: false, } @@ -217,7 +219,7 @@ export default { return { show: isEmptySearch || hasNoResults, - text: this.searching && hasNoResults ? t('core', 'Searching …') : (isEmptySearch ? t('core', 'Start typing in search') : t('core', 'No matching results')), + text: this.searching && hasNoResults ? t('core', 'Searching …') : (isEmptySearch ? t('core', 'Start typing to search') : t('core', 'No matching results')), icon: MagnifyIcon, } }, @@ -242,7 +244,7 @@ export default { this.providers = providers console.debug('Search providers', this.providers) }) - getContacts({ filter: '' }).then((contacts) => { + getContacts({ searchTerm: '' }).then((contacts) => { this.contacts = this.mapContacts(contacts) console.debug('Contacts', this.contacts) }) @@ -362,7 +364,7 @@ export default { }) }, filterContacts(query) { - getContacts({ filter: query }).then((contacts) => { + getContacts({ searchTerm: query }).then((contacts) => { this.contacts = this.mapContacts(contacts) console.debug(`Contacts filtered by ${query}`, this.contacts) }) |