( inputDefsByProperty: InputDefsByProperty<T>, updated: T, contextForChildren: unknown[], )
| 58 | const maxPropertiesForDefaultRollup = 3 |
| 59 | |
| 60 | const buildPropertyChoices = <T>( |
| 61 | inputDefsByProperty: InputDefsByProperty<T>, |
| 62 | updated: T, |
| 63 | contextForChildren: unknown[], |
| 64 | ): Choice<string | HelpAction | CancelAction | FinishAction>[] => { |
| 65 | const choices: Choice<string>[] = [] |
| 66 | for (const propertyName in inputDefsByProperty) { |
| 67 | const propertyInputDefinition = inputDefsByProperty[propertyName] |
| 68 | if (!propertyInputDefinition) { |
| 69 | continue |
| 70 | } |
| 71 | const propertyValue = updated[propertyName] |
| 72 | if (propertyInputDefinition.itemTypeData?.type === 'object' && |
| 73 | (propertyInputDefinition.itemTypeData as ObjectItemTypeData<unknown>).rolledUp) { |
| 74 | // nested property that is rolled up |
| 75 | const itemTypeData = propertyInputDefinition.itemTypeData as ObjectItemTypeData<unknown> |
| 76 | for (const nestedPropertyName in itemTypeData.inputDefsByProperty) { |
| 77 | const nestedPropertyInputDefinition = |
| 78 | (itemTypeData.inputDefsByProperty as { [key: string]: InputDefinition<unknown> })[nestedPropertyName] |
| 79 | const nestedItem = (propertyValue as { [key: string]: unknown })[nestedPropertyName] |
| 80 | const summary = nestedPropertyInputDefinition.summarizeForEdit(nestedItem, contextForChildren) |
| 81 | if (summary !== uneditable) { |
| 82 | choices.push({ |
| 83 | name: `Edit ${nestedPropertyInputDefinition.name}: ${summary}`, |
| 84 | value: `${propertyName}.${nestedPropertyName}`, |
| 85 | }) |
| 86 | } |
| 87 | } |
| 88 | } else { |
| 89 | // top-level property |
| 90 | const summary = propertyInputDefinition.summarizeForEdit(propertyValue, contextForChildren) |
| 91 | if (summary !== uneditable) { |
| 92 | choices.push({ |
| 93 | name: `Edit ${propertyInputDefinition.name}: ${summary}`, |
| 94 | value: propertyName, |
| 95 | }) |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | return choices |
| 100 | } |
| 101 | |
| 102 | // TODO: deal with optional objects |
| 103 | // rolled up: make all items optional or don't allow rollup for optional classes? |
no outgoing calls
no test coverage detected