Merge pull request #14027 from calixteman/14024

Annotation - Checkboxes with the same name and export values must be in unison
This commit is contained in:
calixteman 2021-09-15 15:42:26 +02:00 committed by GitHub
commit 8c2ac85b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -976,25 +976,29 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
const element = document.createElement("input");
element.disabled = data.readOnly;
element.type = "checkbox";
element.name = this.data.fieldName;
element.name = data.fieldName;
if (value) {
element.setAttribute("checked", true);
}
element.setAttribute("id", id);
element.setAttribute("exportValue", data.exportValue);
element.tabIndex = DEFAULT_TAB_INDEX;
element.addEventListener("change", function (event) {
const name = event.target.name;
const checked = event.target.checked;
for (const checkbox of document.getElementsByName(name)) {
if (checkbox !== event.target) {
checkbox.checked = false;
checkbox.checked =
checked &&
checkbox.getAttribute("exportValue") === data.exportValue;
storage.setValue(
checkbox.parentNode.getAttribute("data-annotation-id"),
{ value: false }
);
}
}
storage.setValue(id, { value: event.target.checked });
storage.setValue(id, { value: checked });
});
if (this.enableScripting && this.hasJSActions) {