diff --git a/frontend/app/composables/useEntityTypes.ts b/frontend/app/composables/useEntityTypes.ts index 3b04fbf..92c17e2 100644 --- a/frontend/app/composables/useEntityTypes.ts +++ b/frontend/app/composables/useEntityTypes.ts @@ -7,6 +7,7 @@ import { ref, type Ref } from 'vue' import { useToast } from './useToast' +import { useCustomFieldNameSuggestions } from './useCustomFieldNameSuggestions' import { humanizeError } from '~/shared/utils/errorMessages' import { listModelTypes, @@ -79,6 +80,7 @@ export function invalidateEntityTypeCache(category: ModelCategory) { export function useEntityTypes(config: EntityTypeConfig) { const { category, label } = config const { showSuccess, showError } = useToast() + const { invalidate: invalidateCustomFieldNames } = useCustomFieldNameSuggestions() const state = getOrCreateState(category) const normalizeItem = (item: ModelType): EntityType => ({ @@ -124,6 +126,7 @@ export function useEntityTypes(config: EntityTypeConfig) { }) const normalized = normalizeItem(data) state.types.value.push(normalized) + invalidateCustomFieldNames() showSuccess(`Type de ${label} "${data.name}" créé`) return { success: true, data: normalized } } catch (error) { @@ -150,6 +153,7 @@ export function useEntityTypes(config: EntityTypeConfig) { const normalized = normalizeItem(data) const index = state.types.value.findIndex((t) => t.id === id) if (index !== -1) state.types.value[index] = normalized + invalidateCustomFieldNames() showSuccess(`Type de ${label} "${data.name}" mis à jour`) return { success: true, data: normalized } } catch (error) { diff --git a/frontend/app/composables/useMachineCustomFieldDefs.ts b/frontend/app/composables/useMachineCustomFieldDefs.ts index a4e9a94..fccbb54 100644 --- a/frontend/app/composables/useMachineCustomFieldDefs.ts +++ b/frontend/app/composables/useMachineCustomFieldDefs.ts @@ -1,5 +1,6 @@ import { reactive, ref } from 'vue' import { useApi } from '~/composables/useApi' +import { useCustomFieldNameSuggestions } from '~/composables/useCustomFieldNameSuggestions' import { useToast } from '~/composables/useToast' // --- Types --- @@ -88,6 +89,7 @@ const parseOptions = (optionsText: string): string[] => export function useMachineCustomFieldDefs(deps: Deps) { const { apiCall } = useApi() const { showSuccess, showError } = useToast() + const { invalidate: invalidateCustomFieldNames } = useCustomFieldNameSuggestions() // --- State --- @@ -294,6 +296,7 @@ export function useMachineCustomFieldDefs(deps: Deps) { } showSuccess('Champs personnalisés sauvegardés avec succès') + invalidateCustomFieldNames() await deps.onSaved() } catch { showError('Erreur inattendue lors de la sauvegarde des champs personnalisés')