cob-cli 2.16.0 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -75,10 +75,16 @@ cob.custom.customize.push(function (core, utils, ui) {
|
|
|
75
75
|
let calculations = getAllCalculationsFields()
|
|
76
76
|
calculations.forEach(
|
|
77
77
|
calculation => calculation.args.forEach( arg => {
|
|
78
|
+
// eventos de field changes de qualquer das variáveis (ou seja, sempre que o argumento não for um número)
|
|
78
79
|
if(isNaN(arg)) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
if(arg.field.fieldDefinition.duplicable) {
|
|
81
|
+
//O caso de campos duplicáveis é diferente porque é necessário voltar a registar tudo e só depois calcular
|
|
82
|
+
presenter.onFieldChange(arg.field.fieldDefinition.name, () => registerAndExecuteCalculation() )
|
|
83
|
+
// TODO: reagir à remoção de um duplicado
|
|
84
|
+
} else {
|
|
85
|
+
//No caso de campos normais só é necessário calcular tudo quando uma dependência muda
|
|
86
|
+
presenter.onFieldChange(arg, () => executeCalculations() )
|
|
87
|
+
}
|
|
82
88
|
//Caso o campo tenha uma condição também temos de reagir a mudanças na condição. TODO: reagir a toda a cadeia superior (sempre que haja uma condição ou seja duplicável) e não apenas condição directa
|
|
83
89
|
let conditionFp = presenter.findFieldPs(fp => fp.field.id === arg.field.fieldDefinition.conditionSource)
|
|
84
90
|
if(conditionFp.length) presenter.onFieldChange(conditionFp[0].field.fieldDefinition.name, registerAndExecuteCalculation )
|