-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: custom calculations (DHIS2-13871) #1370
Merged
martinkrulltott
merged 159 commits into
master
from
feat/DHIS2-13871-custom-calculations
Apr 24, 2023
Merged
feat: custom calculations (DHIS2-13871) #1370
martinkrulltott
merged 159 commits into
master
from
feat/DHIS2-13871-custom-calculations
Apr 24, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edoardo
reviewed
Dec 2, 2022
…requests to CalcModal.js
…ons while loading
edoardo
approved these changes
Apr 18, 2023
edoardo
approved these changes
Apr 18, 2023
jenniferarnesen
approved these changes
Apr 20, 2023
janhenrikoverland
approved these changes
Apr 24, 2023
dhis2-bot
added a commit
that referenced
this pull request
Apr 24, 2023
# [25.0.0](v24.10.1...v25.0.0) (2023-04-24) ### Features * custom calculations (DHIS2-13871) ([#1370](#1370)) ([d174e3e](d174e3e)) ### BREAKING CHANGES * requires metadata to be provided for the new EDI dimension type
🎉 This PR is included in version 25.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements DHIS2-13871
Design spec
Relates to dhis2/data-visualizer-app#2232
Key features
edi_cache
prop - @janhenrikoverland 🙏New lingo
EDI:
Expression Dimension Item
, commonly referred to as a "calculation".formula: The actual math formula for the EDI, known in the backend as
expression
.Description
The
DataDimension
component now supports listing, creating and editing EDIs. This consists of several parts:The Data Dimension modal
+ Calculation
button at the bottom of the modal for creating new EDIs (opens the new calculations modal),Calculations
option in the data type filter.The new Calculation modal
Metadata strategy
All metadata needed for the separate parts of the formula in an EDI are handled by the
CalculationModal
internally, i.e. no separate metadata needs to be passed in when theCalculationModal
is opened. This alleviates the consuming apps (namely DV) as they won't need to fetch and store this metadata (which was initially the idea, but turned out to be quite messy).Parsing a formula /
expression
As a formula is created as separate parts in the
CalculationsModal
(as an array) and the backend format forexpression
is a simple string, there are two new helper functions for handling this:parseExpressionToArray
andparseArrayToExpression
. The former uses a regex (curtesy of ChatGPT!) for splitting theexpression
into different parts and maps the parts with providedmetadata
(which is fetched internally, as per the previous section above).Cache handling /
edi_cache
The backend caches requests based on the provided params and thus disregards if an EDI has been updated. To avoid returning a stale cached response after updating an EDI a special
edi_cache
param are sent with each request that changes with the content of the EDI's formula. This is created by sorting a visualisation's expressions, joining them and hashing it all usingcrypto-js/sha1
(curtesy of @janhenrikoverland)BREAKING CHANGE
The data dimension modal now return
Expression Dimension Items
, which require the consuming app to provide the correct metadata for these items.TODO
await
to only continue if the response is ok- [ ] Handle deleting an EDI that is used in an AO - delete is handled by the backed and should always be allowed
expression
<number>
- dnd with "edit mode"Known issues
Numbered list for internal use. italic = fixed
admin
user can't save EDIs (missing permissions, temporarily using usersystem
now instead) - enableF_EXPRESSION_DIMENSION_ITEM
in the user appexpression
of an EDI is changed will return values based on the old/outdatedexpression
- fixed withedi_cache
dimensionItemType
when opening an AO (temporarily hardcoded for now instead) - fixed by backendname
when theshortName
setting is used - fixed by backendexpression
is missing metadata (i.e. no way to map anid
to aname
) - metadata has been addedexpression
value missing from metadata when opening an AO - metadata has been addedTransfer
list (due to outdated metadata in the consuming app's store)Screenshots
New
Calculations
data type and new+ Calculation
buttonNew calculations modal that opens on top of the data dimension modal
Creating a formula with drag-n-drop and/or click/double-click
creating.a.formula.mov
Client-side validation
Searching and filtering