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