feat(piece) : add quantity display and input to composant edit page
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user