[JS] Fix several issues found in pdf in #13269

- app.alert and few other function can use an object as parameter ({cMsg: ...});
  - support app.alert with a question and a yes/no answer;
  - update field siblings when one is changed in an action;
  - stop calculation if calculate is set to false in the middle of calculations;
  - get a boolean for checkboxes when they've been set through annotationStorage instead of a string.
This commit is contained in:
Calixte Denizet 2021-04-20 19:21:52 +02:00
parent 3f187c2c6d
commit 3f29892d63
12 changed files with 224 additions and 50 deletions

View file

@ -94,15 +94,29 @@ function initSandbox(params) {
obj.doc = _document;
obj.fieldPath = name;
obj.appObjects = appObjects;
let field;
if (obj.type === "radiobutton") {
const otherButtons = annotations.slice(1);
field = new RadioButtonField(otherButtons, obj);
} else if (obj.type === "checkbox") {
const otherButtons = annotations.slice(1);
field = new CheckboxField(otherButtons, obj);
} else {
field = new Field(obj);
switch (obj.type) {
case "radiobutton": {
const otherButtons = annotations.slice(1);
field = new RadioButtonField(otherButtons, obj);
break;
}
case "checkbox": {
const otherButtons = annotations.slice(1);
field = new CheckboxField(otherButtons, obj);
break;
}
case "text":
if (annotations.length <= 1) {
field = new Field(obj);
break;
}
obj.siblings = annotations.map(x => x.id).slice(1);
field = new Field(obj);
break;
default:
field = new Field(obj);
}
const wrapped = new Proxy(field, proxyHandler);