From a317ebb8ab8f949b28421bb6caca11dcce0cd75f Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Tue, 31 May 2022 15:26:36 -0400 Subject: [PATCH] add hide logic to options --- .../workbench/menu/design-options/option.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/freesewing.shared/components/workbench/menu/design-options/option.js b/packages/freesewing.shared/components/workbench/menu/design-options/option.js index 3349fb9053a..e6f9bd2ef02 100644 --- a/packages/freesewing.shared/components/workbench/menu/design-options/option.js +++ b/packages/freesewing.shared/components/workbench/menu/design-options/option.js @@ -28,14 +28,15 @@ const values = { bool: props => { const { t } = useTranslation(['app']) const dflt = props.pattern.config.options[props.option].bool - const current = props.gist?.options?.[props.option] + let current = props.gist?.options?.[props.option] + current = current === undefined ? dflt : current; return ( - {props.gist?.options?.[props.option] + {current ? t('yes') : t('no') } @@ -69,7 +70,7 @@ const values = { }, constant: props => { return

No constant val yet

- }, + } } const Tmp = props =>

not yet

@@ -86,18 +87,23 @@ const inputs = { const Option = props => { const { t } = useTranslation([`o_${props.pattern.config.name}`]) - const type = optionType(props.pattern.config.options[props.option]) + const opt = props.pattern.config.options[props.option]; + const type = getOptionType(opt) const Input = inputs[type] const Value = values[type] + const hide = opt.hide && opt.hide(props.draft.settings.options); const toggleBoolean = () => { - const dflt = props.pattern.config.options[props.option].bool + const dflt = opt.bool const current = props.gist?.options?.[props.option] if (typeof current === 'undefined') props.updateGist(['options', props.option], !dflt) else props.unsetGist(['options', props.option]) } + if (hide) { + return
  • + } return (type === 'bool') ? (