@@ -308,7 +317,7 @@ const props = defineProps({
toggleToken: { type: Number, default: 0 },
})
-const emit = defineEmits(['update', 'edit', 'custom-field-update', 'delete'])
+const emit = defineEmits(['update', 'edit', 'custom-field-update', 'delete', 'fill-entity'])
// --- Local reactive data for editing ---
const pieceData = reactive({
diff --git a/frontend/app/components/machine/AddEntityToMachineModal.vue b/frontend/app/components/machine/AddEntityToMachineModal.vue
index f6459ed..1da3c35 100644
--- a/frontend/app/components/machine/AddEntityToMachineModal.vue
+++ b/frontend/app/components/machine/AddEntityToMachineModal.vue
@@ -49,6 +49,12 @@
/>
+
+
+ Aucun item sélectionné — la catégorie sera ajoutée avec le statut "À remplir".
+
+
+
{{ selectedEntitySummary.name }}
@@ -64,10 +70,10 @@
@@ -90,11 +96,12 @@ type EntityKind = 'component' | 'piece' | 'product'
const props = defineProps<{
open: boolean
entityKind: EntityKind
+ prefillTypeId?: string
}>()
const emit = defineEmits<{
close: []
- confirm: [entityId: string]
+ confirm: [payload: { entityId?: string; modelTypeId: string; modelTypeName: string }]
}>()
const selectedTypeId = ref('')
@@ -166,6 +173,10 @@ watch(() => props.open, async (isOpen) => {
if (props.entityKind === 'component') await loadComponentTypes()
else if (props.entityKind === 'piece') await loadPieceTypes()
else await loadProductTypes()
+
+ if (props.prefillTypeId) {
+ selectedTypeId.value = props.prefillTypeId
+ }
})
// Load entities when type changes
@@ -222,8 +233,12 @@ const handleClose = () => {
}
const handleConfirm = () => {
- if (!selectedEntityId.value) return
- emit('confirm', selectedEntityId.value)
+ if (!selectedTypeId.value) return
+ emit('confirm', {
+ entityId: selectedEntityId.value || undefined,
+ modelTypeId: selectedTypeId.value,
+ modelTypeName: selectedTypeName.value,
+ })
resetState()
emit('close')
}
diff --git a/frontend/app/components/machine/MachineComponentsCard.vue b/frontend/app/components/machine/MachineComponentsCard.vue
index 9f29faa..bdaddef 100644
--- a/frontend/app/components/machine/MachineComponentsCard.vue
+++ b/frontend/app/components/machine/MachineComponentsCard.vue
@@ -34,6 +34,7 @@
:toggle-token="collapseToggleToken"
@edit-piece="$emit('edit-piece', $event)"
@delete="$emit('remove-component', component.linkId || component.id)"
+ @fill-entity="(linkId, typeId) => $emit('fill-entity', linkId, typeId)"
/>