|
|
@@ -37,7 +37,7 @@ de quitter si des données ont été modifiées.
|
|
|
<div v-else class="mt-12" />
|
|
|
|
|
|
<!-- Content -->
|
|
|
- <slot v-bind="{ model, entity }" />
|
|
|
+ <slot v-bind="{ modelValue }" />
|
|
|
|
|
|
<!-- Bottom action bar -->
|
|
|
<v-container
|
|
|
@@ -105,16 +105,9 @@ import { useRefreshProfile } from '~/composables/data/useRefreshProfile'
|
|
|
|
|
|
const props = defineProps({
|
|
|
/**
|
|
|
- * Classe de l'ApiModel (ex: Organization, Notification, ...)
|
|
|
+ * Instance de l'ApiModel
|
|
|
*/
|
|
|
- model: {
|
|
|
- type: Function as any as () => typeof ApiModel,
|
|
|
- required: true,
|
|
|
- },
|
|
|
- /**
|
|
|
- * Instance de l'objet
|
|
|
- */
|
|
|
- entity: {
|
|
|
+ modelValue: {
|
|
|
type: Object as () => ApiModel,
|
|
|
required: true,
|
|
|
},
|
|
|
@@ -209,7 +202,7 @@ const closeConfirmationDialog = () => {
|
|
|
formStore.setShowConfirmToLeave(false)
|
|
|
}
|
|
|
|
|
|
-const emit = defineEmits(['update:entity'])
|
|
|
+const emit = defineEmits(['update:model-value'])
|
|
|
|
|
|
|
|
|
// ### Actions du formulaire
|
|
|
@@ -234,10 +227,9 @@ const submit = async (next: string | null = null) => {
|
|
|
try {
|
|
|
usePageStore().loading = true
|
|
|
|
|
|
- // TODO: est-ce qu'il faut re-fetch l'entité après le persist?
|
|
|
- const updatedEntity = await em.persist(props.entity)
|
|
|
+ const updatedEntity = await em.persist(props.modelValue)
|
|
|
|
|
|
- emit('update:entity', updatedEntity)
|
|
|
+ emit('update:model-value', updatedEntity)
|
|
|
|
|
|
if (props.refreshProfile) {
|
|
|
await refreshProfile()
|
|
|
@@ -348,7 +340,7 @@ const cancel = () => {
|
|
|
|
|
|
formStore.setShowConfirmToLeave(false)
|
|
|
|
|
|
- em.reset(props.model, props.entity)
|
|
|
+ em.reset(props.modelValue)
|
|
|
|
|
|
if (requestedLeavingRoute.value !== null) {
|
|
|
navigateTo(requestedLeavingRoute.value)
|
|
|
@@ -367,7 +359,7 @@ const actions = computed(() => {
|
|
|
*/
|
|
|
const onFormChange = async () => {
|
|
|
if (isValid.value) {
|
|
|
- em.save(props.entity)
|
|
|
+ em.save(props.modelValue)
|
|
|
setIsDirty(true)
|
|
|
|
|
|
if (props.onChanged) {
|
|
|
@@ -390,7 +382,7 @@ const validate = async function () {
|
|
|
}
|
|
|
|
|
|
// #### Gestion de l'état dirty
|
|
|
-watch(props.entity, async (newEntity, oldEntity) => {
|
|
|
+watch(props.modelValue, async (newEntity, oldEntity) => {
|
|
|
setIsDirty(true)
|
|
|
})
|
|
|
|