fix(search) : préserver la recherche des listes au retour et ignorer les requêtes annulées
Auto Tag Develop / tag (push) Successful in 58s
Auto Tag Develop / tag (push) Successful in 58s
- DetailHeader / MachineDetailHeader : le bouton Retour utilise router.back() (restaure l'URL précédente avec la query ?q=...) avec fallback sur le chemin nu si pas d'historique applicatif. Corrige la perte de recherche/tri/pagination au retour depuis une page détail (composants, produits, pièces, machines). - ManagementView : détecte l'annulation via controller.signal.aborted au lieu de error.name (ofetch encapsule l'AbortError dans une FetchError), supprimant le toast d'erreur affiché lors d'une nouvelle recherche.
This commit is contained in:
@@ -15,10 +15,10 @@
|
||||
<IconLucideEye v-else class="w-5 h-5 mr-2" aria-hidden="true" />
|
||||
{{ isEditMode ? 'Voir détails' : 'Modifier' }}
|
||||
</button>
|
||||
<NuxtLink :to="backDestination" class="btn btn-ghost btn-sm md:btn-md">
|
||||
<button type="button" class="btn btn-ghost btn-sm md:btn-md" @click="goBack">
|
||||
<IconLucideArrowLeft class="w-4 h-4 mr-1" aria-hidden="true" />
|
||||
{{ backLabel }}
|
||||
</NuxtLink>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -29,6 +29,7 @@ import IconLucideEye from '~icons/lucide/eye'
|
||||
import IconLucideArrowLeft from '~icons/lucide/arrow-left'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const props = defineProps<{
|
||||
title: string
|
||||
@@ -43,12 +44,20 @@ defineEmits<{
|
||||
'toggle-edit': []
|
||||
}>()
|
||||
|
||||
const backDestination = computed(() => {
|
||||
// Retour : on revient à l'URL précédente pour préserver l'état de la liste
|
||||
// (recherche, tri, pagination persistés en query params). Fallback sur le
|
||||
// backLink si pas d'historique applicatif (accès direct, refresh, lien partagé).
|
||||
const goBack = () => {
|
||||
if (route.query.from === 'machine' && route.query.machineId) {
|
||||
return `/machine/${route.query.machineId}`
|
||||
router.push(`/machine/${route.query.machineId}`)
|
||||
return
|
||||
}
|
||||
return props.backLink
|
||||
})
|
||||
if (window.history.state?.back) {
|
||||
router.back()
|
||||
return
|
||||
}
|
||||
router.push(props.backLink)
|
||||
}
|
||||
|
||||
const backLabel = computed(() => {
|
||||
if (route.query.from === 'machine') {
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
>
|
||||
<IconLucidePrinter class="w-4 h-4" aria-hidden="true" />
|
||||
</button>
|
||||
<NuxtLink to="/machines" class="btn btn-ghost btn-sm md:btn-md">
|
||||
<button type="button" class="btn btn-ghost btn-sm md:btn-md" @click="goBack">
|
||||
<IconLucideArrowLeft class="w-4 h-4 mr-1" aria-hidden="true" />
|
||||
Parc machines
|
||||
</NuxtLink>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -52,6 +52,18 @@ import IconLucidePrinter from '~icons/lucide/printer'
|
||||
import IconLucideArrowLeft from '~icons/lucide/arrow-left'
|
||||
|
||||
const { canEdit } = usePermissions()
|
||||
const router = useRouter()
|
||||
|
||||
// Retour : revient à l'URL précédente pour préserver la recherche/filtres du
|
||||
// parc machines (persistés en query params). Fallback vers /machines si pas
|
||||
// d'historique applicatif (accès direct, refresh, lien partagé).
|
||||
const goBack = () => {
|
||||
if (window.history.state?.back) {
|
||||
router.back()
|
||||
return
|
||||
}
|
||||
router.push('/machines')
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
title: string
|
||||
|
||||
@@ -281,7 +281,10 @@ const doRefresh = async ({ resetOffset = false }: { resetOffset?: boolean } = {}
|
||||
limit.value = response.limit
|
||||
}
|
||||
catch (error: unknown) {
|
||||
if (error && typeof error === 'object' && (error as { name?: string }).name === 'AbortError') return
|
||||
// Requête annulée volontairement (nouvelle recherche / démontage) : pas une
|
||||
// vraie erreur. On teste le signal car ofetch encapsule l'AbortError dans
|
||||
// une FetchError, donc error.name n'est pas fiable.
|
||||
if (controller.signal.aborted) return
|
||||
showError(extractErrorMessage(error))
|
||||
}
|
||||
finally {
|
||||
|
||||
Reference in New Issue
Block a user