Skip to content

Commit 3e59c82

Browse files
committed
Attempt to further improve the type selector
- better checkbox handling - better checkbox styling
1 parent db44c1c commit 3e59c82

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

WebUI/Templates/OGoScheduler/SkySchedulerSelectPanel.html

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
white-space: nowrap;
3535
cursor: pointer;
3636
}
37+
.apt-type-dropdown-menu input[type="checkbox"] {
38+
vertical-align: middle;
39+
margin-right: 4px;
40+
position: relative;
41+
top: -1px;
42+
}
3743
.apt-type-dropdown-menu label:hover {
3844
background: #0069d9;
3945
color: #fff;
@@ -68,9 +74,19 @@
6874
});
6975

7076
if (!isOpen) {
77+
var checkboxes = menu.querySelectorAll('input[type="checkbox"]');
78+
var allTypesCheckbox = checkboxes[0];
79+
80+
// If "alle Typen" is selected, visually select all other checkboxes too
81+
if (allTypesCheckbox.checked) {
82+
checkboxes.forEach(function(cb) {
83+
cb.checked = true;
84+
});
85+
}
86+
7187
// Save original state before opening
7288
originalAptTypeState = [];
73-
menu.querySelectorAll('input[type="checkbox"]').forEach(function(cb) {
89+
checkboxes.forEach(function(cb) {
7490
originalAptTypeState.push(cb.checked);
7591
});
7692
menu.style.display = 'block';
@@ -84,13 +100,38 @@
84100
function onAptTypeChanged(checkbox, isAllTypes) {
85101
var menu = checkbox.closest('.apt-type-dropdown-menu');
86102
var checkboxes = menu.querySelectorAll('input[type="checkbox"]');
103+
var allTypesCheckbox = checkboxes[0];
87104

88105
if (isAllTypes) {
89106
// "alle Typen" toggled - sync all others to same state
90107
var newState = checkbox.checked;
91108
checkboxes.forEach(function(cb) {
92-
if (cb !== checkbox) cb.checked = newState;
109+
if (cb !== allTypesCheckbox) cb.checked = newState;
110+
});
111+
// Never allow empty selection - if unchecking all, recheck "alle Typen"
112+
if (!newState) {
113+
allTypesCheckbox.checked = true;
114+
}
115+
}
116+
else {
117+
// Check if all or none of the regular checkboxes are selected
118+
var allSelected = true;
119+
var noneSelected = true;
120+
checkboxes.forEach(function(cb) {
121+
if (cb !== allTypesCheckbox) {
122+
if (!cb.checked) allSelected = false;
123+
if (cb.checked) noneSelected = false;
124+
}
93125
});
126+
// If none selected, auto-select "alle Typen" (and all others)
127+
if (noneSelected) {
128+
checkboxes.forEach(function(cb) {
129+
cb.checked = true;
130+
});
131+
}
132+
else {
133+
allTypesCheckbox.checked = allSelected;
134+
}
94135
}
95136
// Don't submit - wait for OK/Cancel/outside click
96137
}
@@ -139,9 +180,9 @@
139180
><#AptTypeCheckbox/> <#AptTypeLabel/></label
140181
></#AptTypesRepetition
141182
><div class="apt-type-buttons"
142-
><button type="button" onclick="submitAptTypes()">OK</button
143183
><button type="button"
144184
onclick="cancelAptTypes(this)">Cancel</button
185+
><button type="button" onclick="submitAptTypes()">OK</button
145186
></div
146187
></div
147188
></div

0 commit comments

Comments
 (0)