Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from jenkinsci:master #528

Merged
merged 4 commits into from
Dec 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Form checker enhancements for radio
  • Loading branch information
timja committed Dec 19, 2024
commit ede07a543c40abcb6f08db3fe5d048a572c4abc0
35 changes: 23 additions & 12 deletions war/src/main/webapp/scripts/hudson-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,21 +536,24 @@ function findNext(src, filter) {
}

function findFormItem(src, name, directionF) {
var name2 = "_." + name; // handles <textbox field="..." /> notation silently
const name2 = "_." + name; // handles <textbox field="..." /> notation silently
return directionF(src, function (e) {
if (e.tagName == "INPUT" && e.type == "radio" && e.checked == true) {
var r = 0;
while (e.name.substring(r, r + 8) == "removeme") {
//radio buttons have must be unique in repeatable blocks so name is prefixed
r = e.name.indexOf("_", r + 8) + 1;
if (e.tagName === "INPUT" && e.type === "radio" ) {
if (e.checked === true) {
let r = 0;
while (e.name.substring(r, r + 8) === "removeme") {
//radio buttons have must be unique in repeatable blocks so name is prefixed
r = e.name.indexOf("_", r + 8) + 1;
}
return name === e.name.substring(r);
}
return name == e.name.substring(r);
return false
}
return (
(e.tagName == "INPUT" ||
e.tagName == "TEXTAREA" ||
e.tagName == "SELECT") &&
(e.name == name || e.name == name2)
(e.tagName === "INPUT" ||
e.tagName === "TEXTAREA" ||
e.tagName === "SELECT") &&
(e.name === name || e.name === name2)
);
});
}
Expand Down Expand Up @@ -730,7 +733,15 @@ function registerValidator(e) {
console.warn("Unable to find nearby " + name);
return;
}
c.addEventListener("change", checker.bind(e));

if (c.tagName === 'INPUT' && c.type === "radio") {
document.querySelectorAll(`input[name='${c.name}'][type='radio']`)
.forEach(element => {
element.addEventListener("change", checker.bind(e));
})
} else {
c.addEventListener("change", checker.bind(e));
}
}),
);
}
Expand Down