set up new view for skeleton hiearchi
This commit is contained in:
@@ -51,13 +51,13 @@
|
||||
</div>
|
||||
<p class="text-sm text-gray-600 line-clamp-3">{{ type.description || 'Aucune description' }}</p>
|
||||
<div class="text-xs text-gray-500 flex items-center gap-2">
|
||||
<span class="inline-flex items-center gap-1">
|
||||
<span class="inline-flex items-center gap-1">
|
||||
<IconLucideClipboardList class="h-4 w-4" aria-hidden="true" />
|
||||
{{ type.components?.length || 0 }} composant(s)
|
||||
{{ type.componentRequirements?.length || 0 }} famille(s)
|
||||
</span>
|
||||
<span class="inline-flex items-center gap-1">
|
||||
<IconLucideList class="h-4 w-4" aria-hidden="true" />
|
||||
{{ type.machinePieces?.length || 0 }} pièce(s) machine
|
||||
{{ type.pieceRequirements?.length || 0 }} groupe(s) de pièces
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -93,8 +93,8 @@ const createEmptyType = () => ({
|
||||
category: '',
|
||||
maintenanceFrequency: '',
|
||||
customFields: [],
|
||||
machinePieces: [],
|
||||
components: []
|
||||
componentRequirements: [],
|
||||
pieceRequirements: [],
|
||||
})
|
||||
|
||||
const draftType = ref(createEmptyType())
|
||||
@@ -141,36 +141,36 @@ const normalizeCustomFields = (fields = []) =>
|
||||
options: parseOptions(field)
|
||||
}))
|
||||
|
||||
const normalizePrice = (value) => {
|
||||
if (value === undefined || value === null || value === '') return null
|
||||
const num = Number(value)
|
||||
return Number.isFinite(num) ? num : null
|
||||
const toIntegerOrNull = (value, fallback = null) => {
|
||||
if (value === '' || value === undefined || value === null) {
|
||||
return fallback
|
||||
}
|
||||
const parsed = Number(value)
|
||||
return Number.isFinite(parsed) ? parsed : fallback
|
||||
}
|
||||
|
||||
const normalizePieces = (pieces = []) =>
|
||||
pieces
|
||||
.filter(piece => piece?.name && piece.name.trim() !== '')
|
||||
.map(piece => ({
|
||||
name: piece.name,
|
||||
reference: piece.reference || '',
|
||||
constructeur: piece.constructeur || '',
|
||||
emplacement: piece.emplacement || '',
|
||||
prix: normalizePrice(piece.prix),
|
||||
customFields: normalizeCustomFields(piece.customFields || [])
|
||||
const normalizeComponentRequirements = (requirements = []) =>
|
||||
requirements
|
||||
.filter(req => req?.typeComposantId)
|
||||
.map(req => ({
|
||||
typeComposantId: req.typeComposantId,
|
||||
label: req.label?.trim() ? req.label.trim() : undefined,
|
||||
minCount: toIntegerOrNull(req.minCount, 1),
|
||||
maxCount: toIntegerOrNull(req.maxCount, null),
|
||||
required: req.required ?? true,
|
||||
allowNewModels: req.allowNewModels ?? true,
|
||||
}))
|
||||
|
||||
const normalizeComponents = (components = []) =>
|
||||
components
|
||||
.filter(component => component?.name && component.name.trim() !== '')
|
||||
.map(component => ({
|
||||
name: component.name,
|
||||
reference: component.reference || '',
|
||||
constructeur: component.constructeur || '',
|
||||
emplacement: component.emplacement || '',
|
||||
prix: normalizePrice(component.prix),
|
||||
customFields: normalizeCustomFields(component.customFields || []),
|
||||
pieces: normalizePieces(component.pieces || []),
|
||||
subComponents: normalizeComponents(component.subComponents || [])
|
||||
const normalizePieceRequirements = (requirements = []) =>
|
||||
requirements
|
||||
.filter(req => req?.typePieceId)
|
||||
.map(req => ({
|
||||
typePieceId: req.typePieceId,
|
||||
label: req.label?.trim() ? req.label.trim() : undefined,
|
||||
minCount: toIntegerOrNull(req.minCount, 0),
|
||||
maxCount: toIntegerOrNull(req.maxCount, null),
|
||||
required: req.required ?? false,
|
||||
allowNewModels: req.allowNewModels ?? true,
|
||||
}))
|
||||
|
||||
const buildPayload = (typeData) => ({
|
||||
@@ -179,8 +179,8 @@ const buildPayload = (typeData) => ({
|
||||
category: typeData.category,
|
||||
maintenanceFrequency: typeData.maintenanceFrequency,
|
||||
customFields: normalizeCustomFields(typeData.customFields),
|
||||
machinePieces: normalizePieces(typeData.machinePieces),
|
||||
components: normalizeComponents(typeData.components)
|
||||
componentRequirements: normalizeComponentRequirements(typeData.componentRequirements),
|
||||
pieceRequirements: normalizePieceRequirements(typeData.pieceRequirements)
|
||||
})
|
||||
|
||||
const resetForm = () => {
|
||||
|
||||
Reference in New Issue
Block a user