V1 Fonctionnelle (pas de secu de l'api, ni front quali)
This commit is contained in:
@@ -200,38 +200,8 @@ export default {
|
||||
})
|
||||
|
||||
const filteredTexts = computed(() => {
|
||||
let filtered = allTexts.value
|
||||
|
||||
// Recherche textuelle
|
||||
if (searchQuery.value.trim()) {
|
||||
const query = searchQuery.value.toLowerCase().trim()
|
||||
filtered = filtered.filter(text => {
|
||||
return (
|
||||
text.metadata.titre_fr?.toLowerCase().includes(query) ||
|
||||
text.metadata.titre_pt?.toLowerCase().includes(query) ||
|
||||
text.metadata.auteur?.toLowerCase().includes(query) ||
|
||||
text.frenchText?.toLowerCase().includes(query) ||
|
||||
text.patoisText?.toLowerCase().includes(query)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// Filtre par catégorie
|
||||
if (selectedCategory.value) {
|
||||
filtered = filtered.filter(text => text.metadata.categorie === selectedCategory.value)
|
||||
}
|
||||
|
||||
// Filtre par difficulté
|
||||
if (selectedDifficulty.value) {
|
||||
filtered = filtered.filter(text => text.metadata.difficulte === selectedDifficulty.value)
|
||||
}
|
||||
|
||||
// Filtre audio seulement
|
||||
if (onlyWithAudio.value) {
|
||||
filtered = filtered.filter(text => text.hasAudio)
|
||||
}
|
||||
|
||||
return filtered
|
||||
// Ne pas filtrer localement - l'API backend s'en charge
|
||||
return allTexts.value
|
||||
})
|
||||
|
||||
const totalPages = computed(() => {
|
||||
@@ -246,23 +216,39 @@ export default {
|
||||
|
||||
const loadTexts = async () => {
|
||||
try {
|
||||
const texts = await textService.loadAllTexts()
|
||||
// Utiliser l'API de recherche avec les filtres actuels
|
||||
const texts = await textService.searchTexts(searchQuery.value, {
|
||||
category: selectedCategory.value,
|
||||
difficulty: selectedDifficulty.value,
|
||||
onlyWithAudio: onlyWithAudio.value
|
||||
})
|
||||
allTexts.value = texts
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du chargement des textes:', error)
|
||||
// Fallback : charger tous les textes si la recherche échoue
|
||||
try {
|
||||
const allTextsData = await textService.loadAllTexts()
|
||||
allTexts.value = allTextsData
|
||||
} catch (fallbackError) {
|
||||
console.error('Erreur fallback:', fallbackError)
|
||||
allTexts.value = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const performSearch = () => {
|
||||
const performSearch = async () => {
|
||||
currentPage.value = 1
|
||||
await loadTexts()
|
||||
}
|
||||
|
||||
const clearFilters = () => {
|
||||
const clearFilters = async () => {
|
||||
searchQuery.value = ''
|
||||
selectedCategory.value = ''
|
||||
selectedDifficulty.value = ''
|
||||
onlyWithAudio.value = false
|
||||
currentPage.value = 1
|
||||
// IMPORTANT: Recharger via l'API après avoir vidé les filtres
|
||||
await loadTexts()
|
||||
}
|
||||
|
||||
const getTextPreview = (text) => {
|
||||
|
||||
Reference in New Issue
Block a user