add most resent code
This commit is contained in:
parent
b356a0bea3
commit
07bddf5eb9
|
|
@ -140,6 +140,7 @@ const colors = computed(() => {
|
|||
// ---- State ----------------------------------------------------------------
|
||||
|
||||
const exactSearch = ref(false)
|
||||
const sortMode = ref<'relevance' | 'date'>('relevance')
|
||||
|
||||
const groupedHits = ref<SearchGroup[]>([])
|
||||
const total = ref(0)
|
||||
|
|
@ -254,6 +255,8 @@ async function runSearch(q: string, page = 1, append = false) {
|
|||
const typePage = isInfinite ? (append ? currentPage.value + 1 : 1) : page
|
||||
|
||||
try {
|
||||
const shouldSortByDate = sortMode.value === 'date' && q.trim()
|
||||
|
||||
const multi = await documentsApi.multiSearch({
|
||||
multiSearchParameters: {},
|
||||
multiSearchSearchesParameter: {
|
||||
|
|
@ -262,6 +265,7 @@ async function runSearch(q: string, page = 1, append = false) {
|
|||
q: exactSearch.value && q ? `"${q}"` : q || '*',
|
||||
queryBy: QUERY_BY,
|
||||
filterBy: filterBy.value,
|
||||
...(shouldSortByDate ? { sortBy: `$${props.mainCollection}(timestamp:desc)` } : {}),
|
||||
perPage: settings.pageSize,
|
||||
page: typePage,
|
||||
highlightFullFields: QUERY_BY,
|
||||
|
|
@ -428,6 +432,15 @@ watch(exactSearch, () => {
|
|||
if (query.value.trim()) runSearch(query.value, 1, false)
|
||||
})
|
||||
|
||||
watch(sortMode, () => {
|
||||
if (query.value.trim()) {
|
||||
groupedHits.value = []
|
||||
total.value = 0
|
||||
currentPage.value = 1
|
||||
runSearch(query.value, 1, false)
|
||||
}
|
||||
})
|
||||
|
||||
// ---- Selección y carga del detalle ----------------------------------------
|
||||
|
||||
const selectedDocId = ref<string | null>(null)
|
||||
|
|
@ -607,6 +620,18 @@ function metaLocation(meta: DocMeta | undefined): string {
|
|||
>{{ t('search.phrase') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-4 sm:px-6 py-3">
|
||||
<USelect
|
||||
v-if="query.trim()"
|
||||
v-model="sortMode"
|
||||
:items="[
|
||||
{ label: t('search.sort.relevance'), value: 'relevance' },
|
||||
{ label: t('search.sort.date'), value: 'date' }
|
||||
]"
|
||||
size="sm"
|
||||
class="shrink-0 min-w-[130px]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<UAlert
|
||||
v-if="errorMsg"
|
||||
|
|
|
|||
10
lang/en.json
10
lang/en.json
|
|
@ -12,8 +12,12 @@
|
|||
"settings": "Settings",
|
||||
"changelog": "What's New"
|
||||
},
|
||||
"search": {
|
||||
"word": "Word",
|
||||
"search": {
|
||||
"sort": {
|
||||
"relevance": "Normal",
|
||||
"date": "Most recent"
|
||||
},
|
||||
"word": "Word",
|
||||
"phrase": "Phrase",
|
||||
"placeholder": "Search for...",
|
||||
"searching": "Searching...",
|
||||
|
|
@ -83,7 +87,7 @@
|
|||
"development_subtitle_line2": "Come back soon."
|
||||
},
|
||||
"ui": {
|
||||
"copy": "Copy",
|
||||
"copy": "Copy",
|
||||
"draft": "Draft",
|
||||
"empty_bible_studies": "Choose a Bible Study to see the detail",
|
||||
"empty_conferences": "Choose a Conference to see the detail"
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@
|
|||
"hits_per_page": "aciertos por página",
|
||||
"hits_retrieved_in": "aciertos logrados en",
|
||||
"for": "Buscando",
|
||||
"sort": {
|
||||
"relevance": "Normal",
|
||||
"date": "Más recientes"
|
||||
},
|
||||
"word": "Palabra",
|
||||
"phrase": "Frase",
|
||||
"words": "palabras",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@
|
|||
"changelog": "Nouveautés"
|
||||
},
|
||||
"search": {
|
||||
"sort": {
|
||||
"relevance": "Normal",
|
||||
"date": "Plus récents"
|
||||
},
|
||||
"word": "Mot",
|
||||
"phrase": "Phrase",
|
||||
"placeholder": "Rechercher des activités",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@
|
|||
"changelog": "Novidades"
|
||||
},
|
||||
"search": {
|
||||
"sort": {
|
||||
"relevance": "Normal",
|
||||
"date": "Mais recentes"
|
||||
},
|
||||
"word": "Palavra",
|
||||
"phrase": "Frase",
|
||||
"placeholder": "Digite para pesquisar...",
|
||||
|
|
|
|||
Loading…
Reference in New Issue