Merge pull request #42167 from nextcloud/unified-search-improvements

Unified search improvements
pull/42198/head
F. E Noel Nfebe 6 months ago committed by GitHub
commit 63babd2324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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>

@ -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
}

@ -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)
})

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save