Merge branch 'fix/mss-2026-form-conditional' into develop-kristijan
This commit is contained in:
commit
08142a929e
|
|
@ -151,8 +151,9 @@
|
||||||
.msreg .ms-field { min-width: 0; }
|
.msreg .ms-field { min-width: 0; }
|
||||||
.msreg .ms-field select, .msreg .ms-field input { max-width: 100%; }
|
.msreg .ms-field select, .msreg .ms-field input { max-width: 100%; }
|
||||||
|
|
||||||
/* "study plans" block (always visible, required) */
|
/* "study plans" block (shown for students; hidden for parents / "other") */
|
||||||
.msreg .ev-plans { margin-top: 24px; border: 1px solid #EAECF0; border-radius: 12px; background: #FBFCFD; padding: 4px 18px 20px; }
|
.msreg .ev-plans { margin-top: 24px; border: 1px solid #EAECF0; border-radius: 12px; background: #FBFCFD; padding: 4px 18px 20px; }
|
||||||
|
.msreg .ev-plans[hidden] { display: none; }
|
||||||
.msreg .ev-plans-title { font-size: 16px; font-weight: 700; color: #101828; margin: 16px 0 2px; }
|
.msreg .ev-plans-title { font-size: 16px; font-weight: 700; color: #101828; margin: 16px 0 2px; }
|
||||||
.msreg .ev-plans-lead { font-size: 13px; color: #98A2B3; margin: 0 0 6px; }
|
.msreg .ev-plans-lead { font-size: 13px; color: #98A2B3; margin: 0 0 6px; }
|
||||||
.msreg .ev-subhead { font-size: 13px; font-weight: 700; color: #98A2B3; text-transform: uppercase; letter-spacing: 0.05em; margin: 20px 0 10px; }
|
.msreg .ev-subhead { font-size: 13px; font-weight: 700; color: #98A2B3; text-transform: uppercase; letter-spacing: 0.05em; margin: 20px 0 10px; }
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,19 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* ---- role gate: parents and "other" won't study, so hide the study-plans block ---- */
|
||||||
|
(function () {
|
||||||
|
var roleSel = form.querySelector('select[data-name="role"]');
|
||||||
|
var plans = form.querySelector('.ev-plans');
|
||||||
|
if (!roleSel || !plans) return;
|
||||||
|
function syncPlans() {
|
||||||
|
var r = roleSel.value;
|
||||||
|
plans.hidden = (r === 'parent' || r === 'other');
|
||||||
|
}
|
||||||
|
roleSel.addEventListener('change', syncPlans);
|
||||||
|
syncPlans();
|
||||||
|
})();
|
||||||
|
|
||||||
/* ---- multi-select chip groups, if any (kept for compatibility) ---- */
|
/* ---- multi-select chip groups, if any (kept for compatibility) ---- */
|
||||||
[].slice.call(form.querySelectorAll('.ms-multi')).forEach(function (group) {
|
[].slice.call(form.querySelectorAll('.ms-multi')).forEach(function (group) {
|
||||||
[].slice.call(group.querySelectorAll('.ms-chip')).forEach(function (chip) {
|
[].slice.call(group.querySelectorAll('.ms-chip')).forEach(function (chip) {
|
||||||
|
|
@ -82,6 +95,7 @@
|
||||||
function validate() {
|
function validate() {
|
||||||
var ok = true;
|
var ok = true;
|
||||||
[].slice.call(form.querySelectorAll('[data-required="1"]')).forEach(function (el) {
|
[].slice.call(form.querySelectorAll('[data-required="1"]')).forEach(function (el) {
|
||||||
|
if (el.closest('[hidden]')) return; // fields hidden by conditional logic aren't required
|
||||||
if (el.classList.contains('ms-radios')) { if (!el.querySelector('.ms-radio.is-selected')) ok = false; }
|
if (el.classList.contains('ms-radios')) { if (!el.querySelector('.ms-radio.is-selected')) ok = false; }
|
||||||
else if (el.classList.contains('ms-multi')) { if (!el.querySelector('.ms-chip.is-selected')) ok = false; }
|
else if (el.classList.contains('ms-multi')) { if (!el.querySelector('.ms-chip.is-selected')) ok = false; }
|
||||||
else if (el.type === 'checkbox') { if (!el.checked) ok = false; }
|
else if (el.type === 'checkbox') { if (!el.checked) ok = false; }
|
||||||
|
|
@ -95,7 +109,7 @@
|
||||||
var d = {};
|
var d = {};
|
||||||
[].slice.call(form.querySelectorAll('[data-name]')).forEach(function (el) {
|
[].slice.call(form.querySelectorAll('[data-name]')).forEach(function (el) {
|
||||||
var name = el.getAttribute('data-name');
|
var name = el.getAttribute('data-name');
|
||||||
if (el.closest('.ev-cond') && el.closest('.ev-cond').hidden) return; // skip hidden "Other" field
|
if (el.closest('[hidden]')) return; // skip fields in hidden sections (conditional "Other", study plans for parents/others)
|
||||||
if (el.classList.contains('ms-radios')) { var v = radioValue(name); if (v) d[name] = v; }
|
if (el.classList.contains('ms-radios')) { var v = radioValue(name); if (v) d[name] = v; }
|
||||||
else if (el.classList.contains('ms-multi')) {
|
else if (el.classList.contains('ms-multi')) {
|
||||||
var sel = [].slice.call(el.querySelectorAll('.ms-chip.is-selected')).map(function (c) { return c.getAttribute('data-value'); });
|
var sel = [].slice.call(el.querySelectorAll('.ms-chip.is-selected')).map(function (c) { return c.getAttribute('data-value'); });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue