fix: stabilize constructeur selector ui

This commit is contained in:
Matthieu
2025-09-17 16:21:42 +02:00
parent 0a95b90553
commit 8a32ef4bbc
4 changed files with 92 additions and 55 deletions

View File

@@ -81,7 +81,9 @@
<label class="label"><span class="label-text font-medium">Constructeur</span></label>
<ConstructeurSelect
v-if="isEditMode"
v-model="component.constructeurId"
class="w-full"
:model-value="component.constructeurId || component.constructeur?.id || null"
@update:modelValue="handleConstructeurChange"
/>
<div v-else class="input input-bordered input-sm bg-base-200">
<div class="flex flex-col">
@@ -288,6 +290,11 @@ const documentsLoaded = ref(!!(props.component.documents && props.component.docu
const componentDocuments = computed(() => props.component.documents || [])
const documentIcon = (doc) => getFileIcon({ name: doc.filename || doc.name, mime: doc.mimeType })
const handleConstructeurChange = async (value) => {
props.component.constructeurId = value
await updateComponent()
}
const { uploadDocuments, deleteDocument, loadDocumentsByComponent } = useDocuments()
watch(
@@ -301,16 +308,6 @@ watch(
{ immediate: true }
)
watch(
() => props.component.constructeurId,
(newVal, oldVal) => {
if (!props.isEditMode) return
if (oldVal === undefined) return
if (newVal !== oldVal) {
updateComponent()
}
}
)
watch(
() => props.component.documents,