diff --git a/app/components/searchPanel/SearchPanel.vue b/app/components/searchPanel/SearchPanel.vue index 2b1d12d..32a6b7c 100644 --- a/app/components/searchPanel/SearchPanel.vue +++ b/app/components/searchPanel/SearchPanel.vue @@ -15,11 +15,13 @@ interface Props { emptyDetailText: string showDraft?: boolean author?: string + showBibleStudyFilter?: boolean } const props = withDefaults(defineProps(), { showDraft: false, - author: '' + author: '', + showBibleStudyFilter: false }) const QUERY_BY = 'text' @@ -28,7 +30,14 @@ const { $i18n } = useNuxtApp() const t = $i18n.t const { locale } = useI18n() -const filterBy = computed(() => `locale:=${locale.value}`) +const filterBy = computed(() => { + let base = `locale:=${locale.value}` + if (activeBibleStudies.value.length > 0) { + const ids = activeBibleStudies.value.map(bs => bs.id).join(',') + base += ` && $${props.mainCollection}(bible_study:=[${ids}])` + } + return base +}) const REQUEST_TIMEOUT_MS = 15000 const settings = useSettingsStore() @@ -145,6 +154,80 @@ const colors = computed(() => { const exactSearch = ref(false) const sortMode = ref<'relevance' | 'date'>('relevance') +// ---- Filtro bible_study multi-chip (solo para Estudios) -------------------- + +interface BibleStudyChip { + id: number + title: string +} + +const bibleStudyInput = ref(null) +const activeBibleStudies = ref([]) +const isValidating = ref(false) + +async function applyBibleStudyFilter() { + const val = bibleStudyInput.value + if (val === null || val <= 0) return + if (activeBibleStudies.value.some(bs => bs.id === val)) { + toast.add({ title: 'Estudio ya agregado', description: `El estudio #${val} ya está en el filtro`, color: 'info' }) + bibleStudyInput.value = null + return + } + + isValidating.value = true + try { + const res = await documentsApi.multiSearch({ + multiSearchParameters: {}, + multiSearchSearchesParameter: { + searches: [{ + collection: props.mainCollection, + q: '*', + queryBy: 'title', + filterBy: `bible_study:=${val}`, + perPage: 1, + includeFields: 'bible_study,title' + }] + } + }) + + const hit = (res?.results?.[0] as { hits?: Array<{ document: { title?: string } }> })?.hits?.[0] + if (hit) { + activeBibleStudies.value = [...activeBibleStudies.value, { id: val, title: hit.document.title || '' }] + bibleStudyInput.value = null + refetchResults() + } else { + toast.add({ title: 'Estudio no encontrado', description: `No existe el estudio #${val}`, color: 'warning' }) + } + } catch (err) { + console.error('Error validando bible_study', err) + } finally { + isValidating.value = false + } +} + +function removeBibleStudyFilter(id: number) { + activeBibleStudies.value = activeBibleStudies.value.filter(bs => bs.id !== id) + refetchResults() +} + +function clearAllBibleStudyFilters() { + activeBibleStudies.value = [] + refetchResults() +} + +function refetchResults() { + if (!debouncedQuery.value.trim()) { + browseItems.value = [] + runBrowse(1, false) + } else { + groupedHits.value = [] + currentPage.value = 1 + runSearch(query.value, 1, false) + } +} + +// ---------------------------------------------------------------------------- + const groupedHits = ref([]) const total = ref(0) const currentPage = ref(1) @@ -204,6 +287,7 @@ const totalPages = computed(() => const docCache = ref>({}) const { documentsApi } = useTypesenseApi() +const toast = useToast() // ---- Batch fetch de metadatos --------------------------------------------- @@ -631,9 +715,8 @@ function metaLocation(meta: DocMeta | undefined): string { >{{ t('search.phrase') }} -
+
+
+ + + + {{ $t('search.filter') }} + +
+
+ + {{ $t('search.bible_study_chip', { number: bs.id }) }} + + + + {{ $t('search.bible_study_clear') }} + +
+
+ diff --git a/app/pages/index.vue b/app/pages/index.vue index e37d172..583ce13 100755 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -52,7 +52,7 @@ const links = ref([

- Buscador Carpa + {{ $t('nav.search_title') }}

{{ $t('home.instructions') }} diff --git a/lang/en.json b/lang/en.json index 8c6ad3d..9b57730 100644 --- a/lang/en.json +++ b/lang/en.json @@ -10,7 +10,8 @@ "my_list": "My List", "history": "History", "settings": "Settings", - "changelog": "What's New" + "changelog": "What's New", + "search_title": "Search of La Gran Carpa Catedral" }, "search": { "sort": { @@ -19,6 +20,9 @@ }, "word": "Word", "phrase": "Phrase", + "bible_study_placeholder": "Study no...", + "bible_study_chip": "Study #{number} {title}", + "bible_study_clear": "Clear filters", "placeholder": "Search for...", "searching": "Searching...", "tip": "Tip: wrap in \"quotes\" for exact phrase in that order.", diff --git a/lang/es.json b/lang/es.json index 4176530..b7443e4 100644 --- a/lang/es.json +++ b/lang/es.json @@ -11,7 +11,8 @@ "settings": "Configuración", "changelog": "Novedades", "tour": "Toma el tour", - "localeselector": "Selector de idioma" + "localeselector": "Selector de idioma", + "search_title": "Buscador de La Gran Carpa Catedral" }, "tour": { "progress": "{current} de {total}", @@ -34,7 +35,7 @@ "favorites_button": "Botón de favoritos" }, "home": { - "instructions": "Bienvenidos, aquí podrán buscar, entre los Estudios Bíblicos, las conferencias y las entrelíneas que están disponibles en el material de archivo de La Gran Carpa Catedral." + "instructions": "Bienvenidos, aquí podrán buscar, entre los Estudios de las escrituras, las conferencias y las entrelíneas que están disponibles en el material de archivo de La Gran Carpa Catedral." }, "search": { "placeholder": "Buscar...", @@ -63,6 +64,9 @@ "phrase": "Frase", "words": "palabras", "phrases": "frases", + "bible_study_placeholder": "N° de estudio...", + "bible_study_chip": "Estudio #{number} {title}", + "bible_study_clear": "Limpiar filtros", "words_tooltip": "Buscar por palabras", "phrases_tooltip": "Buscar por frases", "instructions": "Selecciona un resultado de búsqueda...", diff --git a/lang/fr.json b/lang/fr.json index 59e3aae..ae746f6 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -10,13 +10,17 @@ "my_list": "Ma liste", "history": "Historique", "settings": "Paramètres", - "changelog": "Nouveautés" + "changelog": "Nouveautés", + "search_title": "Buscador de La Gran Carpa Catedral" }, "search": { "sort": { "relevance": "Normal", "date": "Plus récents" }, + "bible_study_placeholder": "N° d'étude...", + "bible_study_chip": "Étude #{number} {title}", + "bible_study_clear": "Effacer les filtres", "word": "Mot", "phrase": "Phrase", "placeholder": "Rechercher des activités", diff --git a/lang/pt.json b/lang/pt.json index a0ae379..0cd4a40 100644 --- a/lang/pt.json +++ b/lang/pt.json @@ -10,13 +10,17 @@ "my_list": "Minha lista", "history": "Registro", "settings": "Configurações", - "changelog": "Novidades" + "changelog": "Novidades", + "search_title": "Buscador de La Gran Carpa Catedral" }, "search": { "sort": { "relevance": "Normal", "date": "Mais recentes" }, + "bible_study_placeholder": "N° do estudo...", + "bible_study_chip": "Estudo #{number} {title}", + "bible_study_clear": "Limpar filtros", "word": "Palavra", "phrase": "Frase", "placeholder": "Digite para pesquisar...",