Add support for checkboxes printing

This commit is contained in:
Calixte Denizet 2020-07-22 17:10:59 +02:00
parent bf539deada
commit cb60523a15
3 changed files with 164 additions and 15 deletions

View file

@ -542,16 +542,28 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
* @returns {HTMLSectionElement}
*/
render() {
const storage = this.annotationStorage;
const data = this.data;
const id = data.id;
const value = storage.getOrCreateValue(
id,
data.fieldValue && data.fieldValue !== "Off"
);
this.container.className = "buttonWidgetAnnotation checkBox";
const element = document.createElement("input");
element.disabled = this.data.readOnly;
element.disabled = data.readOnly;
element.type = "checkbox";
element.name = this.data.fieldName;
if (this.data.fieldValue && this.data.fieldValue !== "Off") {
if (value) {
element.setAttribute("checked", true);
}
element.addEventListener("change", function (event) {
storage.setValue(id, event.target.checked);
});
this.container.appendChild(element);
return this.container;
}