(command: APICommand, attribute: CapabilityAttribute)
| 179 | } |
| 180 | |
| 181 | export const chooseUnit = async (command: APICommand, attribute: CapabilityAttribute): Promise<string | undefined> => { |
| 182 | let unit |
| 183 | const units = attribute.schema.properties.unit?.enum |
| 184 | if (units) { |
| 185 | const config: SelectFromListConfig<CapabilityUnitItem> = { |
| 186 | itemName: 'unit', |
| 187 | primaryKeyName: 'unit', |
| 188 | sortKeyName: 'unit', |
| 189 | listTableFieldDefinitions: ['unit'], |
| 190 | } |
| 191 | |
| 192 | const listItems = async (): Promise<CapabilityUnitItem[]> => Promise.resolve(units.map(unit => { |
| 193 | return { unit } |
| 194 | })) |
| 195 | |
| 196 | const preselectedId = units.length === 1 ? units[0] : undefined |
| 197 | unit = await selectFromList(command, config, { preselectedId, listItems }) |
| 198 | } |
| 199 | return unit |
| 200 | } |
| 201 | |
| 202 | export const chooseValue = async ( |
| 203 | command: APICommand, |
no test coverage detected