preparation for toggle all/none checkbox in recipientLayout
This commit is contained in:
parent
7e7ba291f2
commit
8fd16c3545
@ -9,8 +9,12 @@ $if not (null activeCategories)
|
|||||||
|
|
||||||
$if hasContent category
|
$if hasContent category
|
||||||
<fieldset .recipient-category__fieldset uw-interactive-fieldset .interactive-fieldset__target data-conditional-input=#{checkedIdent category}>
|
<fieldset .recipient-category__fieldset uw-interactive-fieldset .interactive-fieldset__target data-conditional-input=#{checkedIdent category}>
|
||||||
$forall optIx <- categoryIndices category
|
$if not (null (categoryIndices category))
|
||||||
^{cellWdgts ! optIx}
|
$# TODO: unique id for this all/none checkbox
|
||||||
|
<input type=checkbox id=tbd .recipient-category__toggle-all>
|
||||||
|
<label for=tbd>Label
|
||||||
|
$forall optIx <- categoryIndices category
|
||||||
|
^{cellWdgts ! optIx}
|
||||||
|
|
||||||
$maybe addWdgt <- addWdgts !? (1, (EnumPosition category, 0))
|
$maybe addWdgt <- addWdgts !? (1, (EnumPosition category, 0))
|
||||||
^{addWdgt}
|
^{addWdgt}
|
||||||
|
|||||||
@ -1 +1,34 @@
|
|||||||
// TODO: js utility to check all/none of the checkboxes in a recipient category at once
|
// TODO: js utility to check all/none of the checkboxes in a recipient category at once
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
var RECIPIENT_CATEGORIES_SELECTOR = '.recipient-categories';
|
||||||
|
var RECIPIENT_CATEGORY_SELECTOR = '.recipient-category';
|
||||||
|
var RECIPIENT_CATEGORY_FIELDSET_SELECTOR = '.recipient-category__fieldset';
|
||||||
|
var RECIPIENT_CATEGORY_TOGGLE_ALL_SELECTOR = '.recipient-category__toggle-all';
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|
||||||
|
var recipientCategoriesElement = document.querySelector(RECIPIENT_CATEGORIES_SELECTOR);
|
||||||
|
var recipientCategoryElements = Array.from(recipientCategoriesElement.querySelectorAll(RECIPIENT_CATEGORY_SELECTOR));
|
||||||
|
|
||||||
|
recipientCategoryElements.forEach(function(element) {
|
||||||
|
setupRecipientCategory(element);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function setupRecipientCategory(recipientCategoryElement) {
|
||||||
|
var fieldset = recipientCategoryElement.querySelector(RECIPIENT_CATEGORY_FIELDSET_SELECTOR);
|
||||||
|
var categoryCheckboxes = Array.from(fieldset.querySelectorAll('[type="checkbox"]'));
|
||||||
|
|
||||||
|
if (categoryCheckboxes) {
|
||||||
|
var toggleAllCheckbox = recipientCategoryElement.querySelector(RECIPIENT_CATEGORY_TOGGLE_ALL_SELECTOR);
|
||||||
|
|
||||||
|
if (toggleAllCheckbox) {
|
||||||
|
toggleAllCheckbox.addEventListener('change', function() {
|
||||||
|
console.log('TBD: setting up toggle all checkbox');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user