feat: add Part primitive task selection
This commit is contained in:
@@ -287,8 +287,9 @@ export function createMockFacade(): BitBybitWebCadFacade {
|
||||
const existing = state.document.tree.filter((item) => item.label.toLowerCase().startsWith(base)).length
|
||||
return existing === 0 ? base : `${base}${String(existing).padStart(3, '0')}`
|
||||
}
|
||||
const appendFeature = (document: DocumentSnapshot, commandId: string): { document: DocumentSnapshot; objectId: string } => {
|
||||
const definition = featureCommands[commandId]
|
||||
const appendFeature = (document: DocumentSnapshot, commandId: string, draft: Record<string, unknown> = {}): { document: DocumentSnapshot; objectId: string } => {
|
||||
const primitiveType = commandId === 'primitive' && ['Box', 'Cylinder', 'Sphere', 'Cone'].includes(String(draft.primitiveType)) ? String(draft.primitiveType) : 'Box'
|
||||
const definition = commandId === 'primitive' ? { label: primitiveType, detail: primitiveType === 'Box' ? '10 × 10 × 10 mm' : `${primitiveType} primitive` } : featureCommands[commandId]
|
||||
if (!definition) return { document, objectId: '' }
|
||||
const objectId = nextFeatureId(definition.label)
|
||||
const type = commandId === 'create-sketch' ? 'sketch' : commandId === 'create-body' ? 'body' : 'feature'
|
||||
@@ -472,14 +473,14 @@ export function createMockFacade(): BitBybitWebCadFacade {
|
||||
const applyTask = () => {
|
||||
const task = state.task
|
||||
if (!task || task.status !== 'preview') return
|
||||
const result = appendFeature(state.document, task.commandId)
|
||||
const result = appendFeature(state.document, task.commandId, task.draft)
|
||||
if (!result.objectId) {
|
||||
state = { ...state, task: { ...task, status: 'completed' } }
|
||||
emitState()
|
||||
return
|
||||
}
|
||||
commit({ ...state, document: result.document, selectedObjectId: result.objectId, task: { ...task, status: 'completed' } })
|
||||
notify(`${featureCommands[task.commandId].label} created`)
|
||||
notify(`${result.document.tree.find((item) => item.id === result.objectId)?.label || featureCommands[task.commandId]?.label || task.commandId} created`)
|
||||
}
|
||||
const execute = ({ commandId, payload }: ExecuteCommandInput) => {
|
||||
const requestId = `req-${++requestSequence}`
|
||||
|
||||
Reference in New Issue
Block a user