1
0
Fork 0

wip: Updates to lab to support v3 patterns

This commit is contained in:
Joost De Cock 2022-08-29 17:44:50 +02:00
parent d59bab6a6c
commit a023f1810c
19 changed files with 101 additions and 155 deletions

View file

@ -1,4 +1,5 @@
import get from 'lodash.get'
import set from 'lodash.set'
// Generic rounding method
export const round = (val, decimals=1) => Math.round(val*Math.pow(10, decimals))/Math.pow(10, decimals)
@ -159,3 +160,16 @@ export const measurementAsMm = (value, units = "metric") => {
}
return false;
}
export const optionsMenuStructure = options => {
if (!options) return options
const menu = {}
for (const [name, option] of Object.entries(options)) {
if (typeof option === 'object') {
set(menu, (option.menu ? `${option.menu}.${name}` : name), optionType(option))
}
}
return menu
}