1
0
Fork 0

🐛 Fixed issue in utils/optionDefault with list type options

This commit is contained in:
Joost De Cock 2019-10-02 07:50:01 +02:00
parent a08ba518ab
commit eb2dcf9568
3 changed files with 29 additions and 16 deletions

View file

@ -12,6 +12,8 @@ Unreleased:
waralee: waralee:
- Added the Waralee wrap Pants pattern by @woutervdub - Added the Waralee wrap Pants pattern by @woutervdub
Changed: Changed:
css-theme:
- Made tweaks to the main/sidebar layout
core: core:
- The pattern super constructor now sets a `config` property that - The pattern super constructor now sets a `config` property that
holds the pattern configuration. This means that unlike before, there holds the pattern configuration. This means that unlike before, there
@ -19,6 +21,7 @@ Unreleased:
import the pattern, and it's config property will contain the pattern config. import the pattern, and it's config property will contain the pattern config.
components: components:
- Added Penelope and Waralee linedrawings - Added Penelope and Waralee linedrawings
- Changed animation of the Spinner component
simon: simon:
- "[#123](https://github.com/freesewing/freesewing/issues/123): - "[#123](https://github.com/freesewing/freesewing/issues/123):
Added a box pleat option to Simon" Added a box pleat option to Simon"
@ -32,6 +35,8 @@ Unreleased:
package has been deprecated. Please import our patterns individually. package has been deprecated. Please import our patterns individually.
Removed: Removed:
Fixed: Fixed:
css-theme:
- Reduced the sidebar height by 64px to take navbar into account
components: components:
- Fixed display of nested option in SampleConfigurator - Fixed display of nested option in SampleConfigurator
- Fixed conflicting key values in React components - Fixed conflicting key values in React components
@ -40,6 +45,8 @@ Unreleased:
to be set incorrectly to be set incorrectly
- Added a missing paperless dimension for the waist - Added a missing paperless dimension for the waist
- Fixed an issue where the split yoke option was not taken into account correctly - Fixed an issue where the split yoke option was not taken into account correctly
utils:
- Fixed an issue where optionDefault was not handling list options correctly
Security: Security:
2.0.4: 2.0.4:

View file

@ -264,3 +264,5 @@ cutting: Cutting
instructions: Instructions instructions: Instructions
hide: Hide hide: Hide
show: Show show: Show
oneMomentPlease: One moment please
loadingMagic: We are loading the magic

View file

@ -1,27 +1,31 @@
import optionType from "../optionType"; import optionType from '../optionType'
const optionDefault = (name, option, recipe) => { const optionDefault = (name, option, recipe) => {
let type = optionType(option); let type = optionType(option)
let factor = type === "pct" ? 100 : 1;
// Default from recipe? // Default from recipe?
let fromRecipe = false
if ( if (
recipe && recipe &&
typeof recipe.settings !== "undefined" && typeof recipe.settings !== 'undefined' &&
typeof recipe.settings.options !== "undefined" && typeof recipe.settings.options !== 'undefined' &&
typeof recipe.settings.options[name] !== "undefined" typeof recipe.settings.options[name] !== 'undefined'
) )
return Math.round(10 * recipe.settings.options[name] * factor) / 10; fromRecipe = true
switch (type) { switch (type) {
case "constant": case 'constant':
return option; return option
break; break
case "list": case 'list':
return option.dflt; if (fromRecipe) return recipe.settings.options[name]
break; return option.dflt
break
default: default:
return option[type]; let factor = type === 'pct' ? 100 : 1
if (fromRecipe) return Math.round(10 * recipe.settings.options[name] * factor) / 10
else return option[type]
break
} }
}; }
export default optionDefault; export default optionDefault