feat(commercial) : conserve l'onglet actif entre consultation et edition client
Au passage consultation <-> edition d'un client, l'onglet courant (Information / Contact / Adresse / Comptabilite...) est conserve dans les deux sens, transmis via history.state (l'URL ne change pas — etat d'UI hors URL). - Nouveau util shared readHistoryTab : lit history.state.tab et le valide contre les onglets autorises (fallback Information : navigation directe, refresh, onglet hors role). - Consultation goEdit et edition goBack posent l'onglet courant ; chaque page initialise activeTab depuis l'historique. - Test unitaire du util (present/valide, hors-cles, absent, valeur non-string).
This commit is contained in:
@@ -440,6 +440,7 @@ import {
|
||||
type RibFormDraft,
|
||||
} from '~/modules/commercial/types/clientForm'
|
||||
import { extractApiErrorMessage } from '~/shared/utils/api'
|
||||
import { readHistoryTab } from '~/shared/utils/historyTab'
|
||||
|
||||
// Masques de saisie (la normalisation finale reste serveur).
|
||||
const SIREN_MASK = '#########'
|
||||
@@ -626,11 +627,13 @@ const tabs = computed(() => tabKeys.value.map(key => ({
|
||||
icon: TAB_ICONS[key],
|
||||
})))
|
||||
|
||||
const activeTab = ref('information')
|
||||
// Onglet initial : repris de la consultation (history.state), sinon Information.
|
||||
const activeTab = ref(readHistoryTab(tabKeys.value) ?? 'information')
|
||||
|
||||
// ── Navigation ──────────────────────────────────────────────────────────────
|
||||
/** Retour consultation en conservant l'onglet courant (via history.state). */
|
||||
function goBack(): void {
|
||||
router.push(`/clients/${clientId}`)
|
||||
router.push({ path: `/clients/${clientId}`, state: { tab: activeTab.value } })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -281,6 +281,7 @@
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useClient } from '~/modules/commercial/composables/useClient'
|
||||
import { buildClientFormTabKeys } from '~/modules/commercial/utils/clientFormRules'
|
||||
import { readHistoryTab } from '~/shared/utils/historyTab'
|
||||
import {
|
||||
canEditClient,
|
||||
categoryOptionsOf,
|
||||
@@ -416,15 +417,17 @@ const tabs = computed(() => tabKeys.value.map(key => ({
|
||||
icon: TAB_ICONS[key],
|
||||
})))
|
||||
|
||||
const activeTab = ref('information')
|
||||
// Onglet initial : repris de l'edition au retour (history.state), sinon Information.
|
||||
const activeTab = ref(readHistoryTab(tabKeys.value) ?? 'information')
|
||||
|
||||
// ── Navigation ─────────────────────────────────────────────────────────────
|
||||
function goBack(): void {
|
||||
router.push('/clients')
|
||||
}
|
||||
|
||||
/** Bascule en edition en conservant l'onglet courant (via history.state). */
|
||||
function goEdit(): void {
|
||||
router.push(`/clients/${clientId}/edit`)
|
||||
router.push({ path: `/clients/${clientId}/edit`, state: { tab: activeTab.value } })
|
||||
}
|
||||
|
||||
// ── Archivage / Restauration ────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user