feat: reorganize machine skeleton pages
This commit is contained in:
@@ -203,7 +203,12 @@ import { useComponentModels } from '~/composables/useComponentModels'
|
||||
import { useComponentTypes } from '~/composables/useComponentTypes'
|
||||
import { useToast } from '~/composables/useToast'
|
||||
import ComponentModelStructureEditor from '~/components/ComponentModelStructureEditor.vue'
|
||||
import { formatStructurePreview } from '~/shared/modelUtils'
|
||||
import {
|
||||
formatStructurePreview,
|
||||
defaultStructure,
|
||||
cloneStructure,
|
||||
normalizeStructureForSave,
|
||||
} from '~/shared/modelUtils'
|
||||
import { formatFrenchDate } from '~/utils/date'
|
||||
import IconLucidePlus from '~icons/lucide/plus'
|
||||
import IconLucideLayers from '~icons/lucide/layers'
|
||||
@@ -231,7 +236,7 @@ const form = reactive({
|
||||
name: '',
|
||||
description: '',
|
||||
typeComposantId: '',
|
||||
structure: {}
|
||||
structure: defaultStructure(),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -253,7 +258,7 @@ const startCreate = () => {
|
||||
name: '',
|
||||
description: '',
|
||||
typeComposantId: selectedType.value !== 'all' ? selectedType.value : '',
|
||||
structure: {}
|
||||
structure: defaultStructure(),
|
||||
}
|
||||
ensureTypeSelected()
|
||||
}
|
||||
@@ -265,7 +270,7 @@ const startEdit = (model) => {
|
||||
name: model.name,
|
||||
description: model.description || '',
|
||||
typeComposantId: model.typeComposantId || model.typeComposant?.id || '',
|
||||
structure: model.structure || {}
|
||||
structure: cloneStructure(model.structure || defaultStructure()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +313,7 @@ const handleSubmit = async () => {
|
||||
name: form.data.name.trim(),
|
||||
description: form.data.description.trim() || undefined,
|
||||
typeComposantId: form.data.typeComposantId,
|
||||
structure: form.data.structure || {}
|
||||
structure: normalizeStructureForSave(form.data.structure),
|
||||
})
|
||||
if (!result.success) {
|
||||
showError(result.error || 'Impossible de créer le modèle')
|
||||
@@ -320,7 +325,7 @@ const handleSubmit = async () => {
|
||||
name: form.data.name.trim(),
|
||||
description: form.data.description.trim() || undefined,
|
||||
typeComposantId: form.data.typeComposantId,
|
||||
structure: form.data.structure || {}
|
||||
structure: normalizeStructureForSave(form.data.structure),
|
||||
})
|
||||
if (!result.success) {
|
||||
showError(result.error || 'Impossible de mettre à jour le modèle')
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<h2 class="text-2xl font-bold text-gray-800">
|
||||
Squelettes de machine
|
||||
</h2>
|
||||
<NuxtLink to="/generator" class="btn btn-primary">
|
||||
<NuxtLink to="/machine-skeleton/new" class="btn btn-primary">
|
||||
<IconLucidePlus
|
||||
class="w-5 h-5 mr-2"
|
||||
aria-hidden="true"
|
||||
Reference in New Issue
Block a user