Spaces:
Running
Running
Commit ·
5ce4ce7
1
Parent(s): fc71928
Implement auto-check for checkboxes in env-builder
Browse filesAdded auto-check functionality for checkboxes based on card state.
- env-builder.js +19 -0
env-builder.js
CHANGED
|
@@ -2011,6 +2011,9 @@ function collect() {
|
|
| 2011 |
document.querySelectorAll('[data-key]').forEach(el => {
|
| 2012 |
const key = el.dataset.key;
|
| 2013 |
if (!key || !safeKey(key)) return;
|
|
|
|
|
|
|
|
|
|
| 2014 |
const val = String(el.value ?? '').trim();
|
| 2015 |
if (val) obj[key] = val;
|
| 2016 |
});
|
|
@@ -2124,6 +2127,14 @@ function applyObj(obj, replace = false) {
|
|
| 2124 |
markSelected(); filter(); refresh();
|
| 2125 |
}
|
| 2126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2127 |
function handlePickerChange(sel) {
|
| 2128 |
const key = sel.dataset.pickFor;
|
| 2129 |
const mode = sel.closest('[data-picker-shell]')?.dataset.pickerMode || 'single';
|
|
@@ -2142,6 +2153,7 @@ function handlePickerChange(sel) {
|
|
| 2142 |
inp.value = value;
|
| 2143 |
}
|
| 2144 |
sel.value = '';
|
|
|
|
| 2145 |
refresh();
|
| 2146 |
}
|
| 2147 |
|
|
@@ -2166,6 +2178,7 @@ function promptCustomModel(btn) {
|
|
| 2166 |
} else {
|
| 2167 |
inp.value = val;
|
| 2168 |
}
|
|
|
|
| 2169 |
refresh();
|
| 2170 |
}
|
| 2171 |
|
|
@@ -2196,6 +2209,12 @@ function toggleField(key) {
|
|
| 2196 |
btn.textContent = on ? 'On' : 'Off';
|
| 2197 |
btn.classList.toggle('on', on);
|
| 2198 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2199 |
refresh();
|
| 2200 |
}
|
| 2201 |
|
|
|
|
| 2011 |
document.querySelectorAll('[data-key]').forEach(el => {
|
| 2012 |
const key = el.dataset.key;
|
| 2013 |
if (!key || !safeKey(key)) return;
|
| 2014 |
+
// Only include if the card's checkbox is ticked
|
| 2015 |
+
const chk = document.querySelector(`[data-check="${CSS.escape(key)}"]`);
|
| 2016 |
+
if (!chk || !chk.checked) return;
|
| 2017 |
const val = String(el.value ?? '').trim();
|
| 2018 |
if (val) obj[key] = val;
|
| 2019 |
});
|
|
|
|
| 2127 |
markSelected(); filter(); refresh();
|
| 2128 |
}
|
| 2129 |
|
| 2130 |
+
function autoCheck(key) {
|
| 2131 |
+
const chk = document.querySelector(`[data-check="${CSS.escape(key)}"]`);
|
| 2132 |
+
if (chk && !chk.checked) {
|
| 2133 |
+
chk.checked = true;
|
| 2134 |
+
markSelected();
|
| 2135 |
+
}
|
| 2136 |
+
}
|
| 2137 |
+
|
| 2138 |
function handlePickerChange(sel) {
|
| 2139 |
const key = sel.dataset.pickFor;
|
| 2140 |
const mode = sel.closest('[data-picker-shell]')?.dataset.pickerMode || 'single';
|
|
|
|
| 2153 |
inp.value = value;
|
| 2154 |
}
|
| 2155 |
sel.value = '';
|
| 2156 |
+
autoCheck(key);
|
| 2157 |
refresh();
|
| 2158 |
}
|
| 2159 |
|
|
|
|
| 2178 |
} else {
|
| 2179 |
inp.value = val;
|
| 2180 |
}
|
| 2181 |
+
autoCheck(key);
|
| 2182 |
refresh();
|
| 2183 |
}
|
| 2184 |
|
|
|
|
| 2209 |
btn.textContent = on ? 'On' : 'Off';
|
| 2210 |
btn.classList.toggle('on', on);
|
| 2211 |
}
|
| 2212 |
+
// Auto-check when turned on; uncheck when turned off
|
| 2213 |
+
const chk = document.querySelector(`[data-check="${CSS.escape(key)}"]`);
|
| 2214 |
+
if (chk) {
|
| 2215 |
+
chk.checked = on;
|
| 2216 |
+
markSelected();
|
| 2217 |
+
}
|
| 2218 |
refresh();
|
| 2219 |
}
|
| 2220 |
|