feat(piece) : add quantity display and input to composant edit page

This commit is contained in:
Matthieu
2026-03-12 14:40:55 +01:00
parent 721963449b
commit 9b40f9f2c7
2 changed files with 16 additions and 1 deletions

View File

@@ -166,9 +166,20 @@
<div v-if="structureSelections.pieces.length" class="space-y-2">
<h3 class="font-semibold text-sm text-base-content">Pièces choisies</h3>
<ul class="list-disc list-inside space-y-1 text-sm">
<li v-for="entry in structureSelections.pieces" :key="`selected-piece-${entry.path}-${entry.id}`">
<li v-for="entry in structureSelections.pieces" :key="`selected-piece-${entry.path}-${entry.id}`" class="flex items-center gap-2">
<span class="font-medium">{{ entry.resolvedName }}</span>
<span v-if="(entry.quantity ?? 1) > 1" class="text-sm text-base-content/60">×{{ entry.quantity }}</span>
<span class="text-xs text-base-content/70"> {{ entry.requirementLabel }}</span>
<input
v-if="canEdit && entry._definition"
v-model.number="entry._definition.quantity"
type="number"
:min="1"
step="1"
placeholder="Qté"
class="input input-bordered input-xs w-16 ml-auto"
@input="entry._definition.quantity = Math.max(1, entry._definition.quantity || 1)"
/>
</li>
</ul>
</div>

View File

@@ -3,6 +3,8 @@ export type SelectionEntry = {
path: string
requirementLabel: string
resolvedName: string
quantity?: number
_definition?: Record<string, any>
}
export type StructureSelectionResult = {
@@ -59,6 +61,8 @@ export function collectStructureSelections(
path: isNonEmptyString(entry?.path) ? entry.path : `${nodePath}:piece-${index + 1}`,
requirementLabel: resolvers.resolvePieceLabel(definition),
resolvedName: catalogPiece?.name || selectedId,
quantity: typeof definition?.quantity === 'number' ? definition.quantity : undefined,
_definition: definition,
})
})