| 1 |
function RedNaoFormula(formElement,formula) |
| 2 |
{ |
| 3 |
this.FormElement=formElement; |
| 4 |
this.Formula=formula; |
| 5 |
} |
| 6 |
|
| 7 |
RedNaoFormula.prototype.FieldUsedInFormula=function(fieldName) |
| 8 |
{ |
| 9 |
for(var i=0;i<this.Formula.FieldsUsed.length;i++) |
| 10 |
{ |
| 11 |
if(fieldName==this.Formula.FieldsUsed[i]) |
| 12 |
return true; |
| 13 |
} |
| 14 |
|
| 15 |
return false; |
| 16 |
} |
| 17 |
|
| 18 |
RedNaoFormula.prototype.UpdateFieldWithValue=function(value) |
| 19 |
{ |
| 20 |
var calculatedValue=eval(this.Formula.CompiledFormula)(value); |
| 21 |
if(typeof calculatedValue=='number'&&isNaN(calculatedValue)) |
| 22 |
calculatedValue=0; |
| 23 |
RedNaoBasicManipulatorInstance.SetValue(this.FormElement.Options,this.Formula.PropertyName,calculatedValue,this.Formula.additionalInformation); |
| 24 |
this.FormElement.RefreshElement(); |
| 25 |
} |