[JS] Take into account all the required fields for some computations

- Fix Field::getArray in order to collect only the fields which have a value;
- Fix AFSimple_Calculate:
  * allow to have a string with a list of field names as argument;
  * since a field can be non-terminal, use Field::getArray to collect
    the field under it and then apply the calculation on all the descendants.
This commit is contained in:
Calixte Denizet 2022-10-13 15:48:01 +02:00
parent c6cc7c6e6a
commit e756bb69e4
4 changed files with 154 additions and 10 deletions

View file

@ -500,14 +500,18 @@ class AForm {
const event = globalThis.event;
const values = [];
cFields = this.AFMakeArrayFromList(cFields);
for (const cField of cFields) {
const field = this._document.getField(cField);
if (!field) {
continue;
}
const number = this.AFMakeNumber(field.value);
if (number !== null) {
values.push(number);
for (const child of field.getArray()) {
const number = this.AFMakeNumber(child.value);
if (number !== null) {
values.push(number);
}
}
}