diff options
author | Eduardo Morales <emoral435@gmail.com> | 2023-12-26 11:33:11 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-26 11:33:11 -0600 |
commit | 2c8fa3efb52b20b1c8bf00a132d312a721c122bd (patch) | |
tree | 094839a85781829a83f7ef9f89e241abe1e5485a /core | |
parent | db3d81a06baefb51fecc755343dc724c75ccac30 (diff) | |
parent | 67a874a6f9e3a742e9159d14eb2fef1ab92be307 (diff) | |
download | nextcloud-server-2c8fa3efb52b20b1c8bf00a132d312a721c122bd.tar.gz nextcloud-server-2c8fa3efb52b20b1c8bf00a132d312a721c122bd.zip |
Merge pull request #42432 from nextcloud/42167-manual-backport
[stable28] Backport unified search improvments
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..9e16fe1880c 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: authenticatedUser.displayName, + emailAddresses: [], + } + contacts.unshift(authenticatedUser) + return contacts + } + return contacts } diff --git a/core/src/views/UnifiedSearchModal.vue b/core/src/views/UnifiedSearchModal.vue index 1d6b138fdb3..8d2d2820495 100644 --- a/core/src/views/UnifiedSearchModal.vue +++ b/core/src/views/UnifiedSearchModal.vue @@ -55,6 +55,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> @@ -192,12 +193,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, } @@ -216,7 +218,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, } }, @@ -241,7 +243,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) }) @@ -361,7 +363,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) }) |