From 74a6028c7660ea2cd59aca98289e2d209e7df085 Mon Sep 17 00:00:00 2001
From: Joshua Ramon Enslin
Date: Sun, 1 Sep 2019 21:16:37 +0200
Subject: [PATCH] Add function to auto-select dependent fields
---
assets/js/csvxml-overview.js | 12 ++++++++++++
index.php | 15 +++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/assets/js/csvxml-overview.js b/assets/js/csvxml-overview.js
index ef9efd3..a11fd7a 100644
--- a/assets/js/csvxml-overview.js
+++ b/assets/js/csvxml-overview.js
@@ -39,6 +39,18 @@
field.textContent = newValue;
field.classList.toggle("humanTLToggled");
+ if (field.classList.contains("humanTLToggled") === false) return;
+
+ let dependencies = field.getAttribute("data-dependencies");
+ if (dependencies !== undefined && dependencies !== null) {
+ let linkedFields = dependencies.split(";");
+ for (let i = 0, max = linkedFields.length; i < max; i++) {
+ let linkedField = document.getElementById(linkedFields[i]);
+ if (linkedField.classList.contains("humanTLToggled") === true) continue;
+ toggleListFieldSelectionState(linkedField);
+ }
+ }
+
}
doForFieldList(function(field) {
diff --git a/index.php b/index.php
index 7e2d486..f31fe66 100644
--- a/index.php
+++ b/index.php
@@ -66,7 +66,8 @@ require __DIR__ . "/values/availableFields.php";
$tooltips = [];
foreach ($availableFields as $headline => $fields) {
- echo "{$headline}
+ echo "
+ {$headline}
";
@@ -76,10 +77,14 @@ foreach ($availableFields as $headline => $fields) {
else $hasTooltip = false;
echo "
-- {$fieldName}";
+ echo "'";
+ if (!empty($field['dependsOn'])) {
+ echo " data-dependencies='" . htmlspecialchars(implode(";", $field['dependsOn'])) . "'";
+ }
+ echo ">{$fieldName}";
if (!empty($field['explica'])) $toolTipExplica = "
General
" . $field['explica'];
else $toolTipExplica = "";
@@ -88,7 +93,9 @@ foreach ($availableFields as $headline => $fields) {
echo "";
}
- echo '';
+ echo '
+
+';
}