reintroduce explicit interactive fieldset target but keep it optional

This commit is contained in:
Felix Hamann 2019-04-21 17:22:22 +02:00
parent bfeb560d5d
commit b74de0f88d
3 changed files with 7 additions and 5 deletions

View File

@ -146,7 +146,7 @@
var INTERACTIVE_FIELDSET_UTIL_NAME = 'interactiveFieldset';
var INTERACTIVE_FIELDSET_UTIL_SELECTOR = '[uw-interactive-fieldset]';
var INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR = '.interactive-fieldset--target';
var INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR = '.interactive-fieldset__target';
var INTERACTIVE_FIELDSET_INITIALIZED_CLASS = 'interactive-fieldset--initialized';
var INTERACTIVE_FIELDSET_CHILD_SELECTOR = 'input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled])';
@ -182,8 +182,10 @@
}
conditionalValue = element.dataset.conditionalValue;
// check if there is a target ancestor, otherwise target the fieldset itself
target = element.closest(INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR) || element;
target = element.closest(INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR);
if (!target || element.matches(INTERACTIVE_FIELDSET_UTIL_TARGET_SELECTOR)) {
target = element;
}
childInputs = Array.from(element.querySelectorAll(INTERACTIVE_FIELDSET_CHILD_SELECTOR));

View File

@ -11,7 +11,7 @@ $case formLayout
<h3 .form-section-title>
^{fvLabel view}
$else
<div .form-group :fvRequired view:.form-group--required :not $ fvRequired view:.form-group--optional :isJust $ fvErrors view:.form-group--has-error>
<div .form-group .interactive-fieldset__target :fvRequired view:.form-group--required :not $ fvRequired view:.form-group--optional :isJust $ fvErrors view:.form-group--has-error>
$if not (Blaze.null $ fvLabel view)
<label .form-group-label for=#{fvId view}>
<span .form-group-label__caption>

View File

@ -6,7 +6,7 @@ $forall category <- activeCategories
_{category}
$# TODO: only add fieldset if there are options to choose from
<fieldset .recipient-category__fieldset uw-interactive-fieldset data-conditional-input=#{checkedIdent category}>
<fieldset .recipient-category__fieldset uw-interactive-fieldset .interactive-fieldset__target data-conditional-input=#{checkedIdent category}>
$forall optIx <- categoryIndices category
^{cellWdgts ! optIx}