IDEMSInternational / open-app-builder

PLH App Frontend
GNU General Public License v3.0
6 stars 25 forks source link

[Discussion] Template calc system improvements #2131

Open chrismclarke opened 11 months ago

chrismclarke commented 11 months ago

Details As part of work on plh a number of custom calc functions were required to simplify what would otherwise be very complex templating logic (#2127). These calculations are currently hardcoded in to the app, however we will want to come up with a better system for extending calc functions more generally.

A couple potential solutions Config-based calculations Could support a field in app config to provide custom calculations. The benefit of this would be ease of integration with the existing calc statements (just needs a line to import from app config) and using existing app compiler to support calcs written in typescript/esnext). Drawback would be harder to share functions across deployments

Flow-based calculations Provide a custom flow type from which users can define calculations to be made globally available. The benefits of this would be more accessible to authors (?) and ability to share across deployments, drawbacks would be the calcs being one step further removed from runtime environment so would likely need custom parser/interpreter to ensure syntax is valid

Additional Considerations