mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 10:40:40 -04:00
Merge pull request #42432 from nextcloud/42167-manual-backport
[stable28] Backport unified search improvments
This commit is contained in:
commit
2c8fa3efb5
5 changed files with 29 additions and 7 deletions
|
|
@ -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: authenticatedUser.displayName,
|
||||
emailAddresses: [],
|
||||
}
|
||||
contacts.unshift(authenticatedUser)
|
||||
return contacts
|
||||
}
|
||||
|
||||
return contacts
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
|
|
|
|||
4
dist/core-unified-search.js
vendored
4
dist/core-unified-search.js
vendored
File diff suppressed because one or more lines are too long
2
dist/core-unified-search.js.map
vendored
2
dist/core-unified-search.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue