← All changes
|
resources/backend/js/settings-conditional-display.js
+25
-1
3.3.1
→
3.4.3
View file →
| @@ -64,9 +64,33 @@ | ||
| 64 | 64 | }); |
| 65 | 65 | break; |
| 66 | 66 | |
| 67 | 67 | default: |
| 68 | - // Iterate through the table rows, hiding any settings. | |
| 68 | + // Group pattern: source has data-conditional-class-prefix; rows opt | |
| 69 | + // into the group by declaring a CSS class of the form | |
| 70 | + // "<prefix><value>". Rows in the group whose class matches the | |
| 71 | + // source's current value are shown; other rows in the group are | |
| 72 | + // hidden. Rows without any matching prefix class are left alone. | |
| 73 | + if (input.dataset.conditionalClassPrefix) { | |
| 74 | + const prefix = input.dataset.conditionalClassPrefix; | |
| 75 | + const expectedClass = prefix + input.value; | |
| 76 | + rows.forEach(function (row) { | |
| 77 | + const inGroup = Array.from(row.classList).some((c) => | |
| 78 | + c.startsWith(prefix) | |
| 79 | + ); | |
| 80 | + if (!inGroup) { | |
| 81 | + return; | |
| 82 | + } | |
| 83 | + row.style.display = row.classList.contains(expectedClass) | |
| 84 | + ? '' | |
| 85 | + : 'none'; | |
| 86 | + }); | |
| 87 | + break; | |
| 88 | + } | |
| 89 | + | |
| 90 | + // Single-target pattern: source has data-conditional-element (id) | |
| 91 | + // and data-conditional-value; the matching row is shown when the | |
| 92 | + // source value equals the expected value and hidden otherwise. | |
| 69 | 93 | rows.forEach(function (row) { |
| 70 | 94 | // Skip if this table row is for the setting we've just changed. |
| 71 | 95 | if (row.querySelector(`[id = "${input.id}"]`)) { |
| 72 | 96 | return; |