Enabling automated calculations through conditional properties #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This small features uses the infrastructure for conditions in a different way. The newly added condition is called calculate. It does not hide properties, the spoken logic essentially is: "If properties a and b are set, this property can be filled in automatically based on the values of a and b".
Let's look at a small and simplistic JSON example to explain this further:
Once the user fills in meters and seconds with values, meters per seconds gets automatically filled in. If i fill in mps and meters, seconds will be automatically calculated. This is useful for any sort of numerical data that is correlated but where initially it is not clear what values the user will provide/has measured.
property_names is renamed to the plural here, since it expects an array of other properties.
digits is simply the number of decimal places to round the result to
formula is obviously the calculation formula and essentially just a wrapper for math.js.evaluate
Linked property names in the formula will be replaced with their respective values before mathematical evaluation.