diff --git a/Resources/public/js/chill.js b/Resources/public/js/chill.js
index 0899f1a4d..a7d661679 100644
--- a/Resources/public/js/chill.js
+++ b/Resources/public/js/chill.js
@@ -355,6 +355,60 @@ var chill = function() {
}
});
}
+
+ function _displayHideTargetWithCheckbox(checkbox) {
+ var target = checkbox.dataset.displayTarget,
+ hideableElements;
+
+ hideableElements = document.querySelectorAll('[data-display-show-hide="' + target + '"]');
+
+ if (checkbox.checked) {
+ for (let i=0; i < hideableElements.length; i = i+1) {
+ hideableElements[i].style.display = "unset";
+ }
+ } else {
+ for (let i=0; i < hideableElements.length; i = i+1) {
+ hideableElements[i].style.display = "none";
+ }
+ }
+
+ }
+
+ /**
+ * create an interaction between a checkbox and element to show if the
+ * checkbox is checked, or hide if the checkbox is not checked.
+ *
+ * The checkbox must have the data `data-display-target` with an id,
+ * and the parts to show/hide must have the data `data-display-show-hide`
+ * with the same value.
+ *
+ * Example :
+ *
+ * ```
+ *
+ *
+ *
+ *
+ *
+ * ```
+ *
+ * Hint: for forms in symfony, you could use the `id` of the form element,
+ * accessible through `{{ form.vars.id }}`. This id should be unique.
+ *
+ *
+ * @returns {undefined}
+ */
+ function listenerDisplayCheckbox() {
+ var elements = document.querySelectorAll("[data-display-target]");
+
+ for (let i=0; i < elements.length; i = i+1) {
+ elements[i].addEventListener("change", function(e) {
+ _displayHideTargetWithCheckbox(e.target);
+ });
+ // initial display-hide
+ _displayHideTargetWithCheckbox(elements[i]);
+ }
+ }
return {
initPikaday: initPikaday,
@@ -364,5 +418,6 @@ var chill = function() {
displayAlertWhenLeavingUnsubmittedForm: displayAlertWhenLeavingUnsubmittedForm,
checkNullValuesInChoices: checkNullValuesInChoices,
categoryLinkParentChildSelect: categoryLinkParentChildSelect,
+ listenerDisplayCheckbox: listenerDisplayCheckbox,
};
} ();
diff --git a/Resources/views/Export/new.html.twig b/Resources/views/Export/new.html.twig
index c4502efbd..95983376d 100644
--- a/Resources/views/Export/new.html.twig
+++ b/Resources/views/Export/new.html.twig
@@ -20,6 +20,12 @@
{% block title %}{{ export.title|trans }}{% endblock %}
+{% block js %}
+
+{% endblock js %}
+
{% block layout_wvm_content %}
{{ export.title|trans }}
@@ -32,14 +38,16 @@
{{ 'Filters'| trans }}
{% for filter_form in form.children.export.children.filters %}
+