-
Notifications
You must be signed in to change notification settings - Fork 3
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(DHIS2-16132): transpose section forms #367
Conversation
🚀 Deployed on https://pr-367--dhis2-data-entry.netlify.app |
a0b968b
to
019f2e6
Compare
63252c7
to
30f0481
Compare
30f0481
to
b33b9e8
Compare
b33b9e8
to
ade9622
Compare
ade9622
to
1993cdd
Compare
feat: add ability to transpose/pivot a section form refactor: change file structure to separate transposed from grouped test: add missed tests
1993cdd
to
14b1b94
Compare
@@ -27,6 +27,20 @@ export function usePeriodId() { | |||
return useQueryParam('periodId', PARAMS_SCHEMA.periodId) | |||
} | |||
|
|||
export function useFeature(feature) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this "feature toggle" in order to be able to test the functionality without the backend and maintenance app deployed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it easy for testing 😅, but I'm not sure we actually would want to expose a query parameter like this? I think people who design data sets would not want their users to arbitrarily transpose things (I assume we're not going to advertise this, but I guess it's possible that people share links if we expose it?)
There aren't really checks for this, so providing invalid categories causes some issues, but maybe that's not of concern if it's just for testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed a test that mimics what we do before (based on the whole metadata) - this file can/should be significantly reduced to only include what's relevant to the test but that wasn't easy to do. I have it in my list for the refactors after (as well as getting rid of snapshot tests)
) | ||
} | ||
|
||
if (fieldInRow.type === 'de') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one thing about my implementation of the matrix generation is that it also generates the data element entry fields. The previous implementation had this as a component concern, and I think that was cleaner - so as part of the consolidating these components, I will also follow the previous approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Yeah I think the data-structure could just return the Ids, and the component would get the dataElement in component-level? But it doesn't matter too much I think.
But I think it makes sense that it generates the structure for them - since now everything is intertwined. It's not as simple as looping over dataElements and categoryOptionsCombos anymore. One row is not always equal to the cocs.length anylonger, so I'm not sure how easy it is to do this on component level?
I guess the structure would have the rows (dataElements and categories), and the headers, and could loop from that info. But I think this is fine for now.
...ategory-combo-table-body-pivoted/generate-form-matrix/generate-matrix-grouped-by-category.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks cool as a new feature, and seems like it's working for the most part (with some issues in how the transposition is actually being rendered).
I'm approving now given the time frame, but I'm not sure if it is really necessary to update this app in time for the soft freeze, or if would be better to resolve the existing issues before merging in?
...rkspace/category-combo-table-body-pivoted/generate-form-matrix/generate-matrix-transposed.js
Show resolved
Hide resolved
src/data-workspace/category-combo-table-body-pivoted/category-combo-table-body-pivoted.js
Outdated
Show resolved
Hide resolved
@@ -27,6 +27,20 @@ export function usePeriodId() { | |||
return useQueryParam('periodId', PARAMS_SCHEMA.periodId) | |||
} | |||
|
|||
export function useFeature(feature) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it easy for testing 😅, but I'm not sure we actually would want to expose a query parameter like this? I think people who design data sets would not want their users to arbitrarily transpose things (I assume we're not going to advertise this, but I guess it's possible that people share links if we expose it?)
There aren't really checks for this, so providing invalid categories causes some issues, but maybe that's not of concern if it's just for testing?
4e0a2f9
to
a939679
Compare
@tomzemp thanks for testing - I fix the issue with the transposed form with one default combo or one category. Below is how it looks. Also removed the cool 🕶️ feature toggle. |
# [100.4.0](v100.3.10...v100.4.0) (2024-03-05) ### Features * **DHIS2-16132:** add ability to transpose/pivot a section form ([#367](#367)) ([1d841ab](1d841ab))
🎉 This PR is included in version 100.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR implements the ability to display sections transposed, and grouped by category in the data entry app. Implements DHIS2-16132 .
transpose-different-options.webm
Default Section form - without pivoting (existing implementation)
Form pivoted (data elements moved to columns)
Single Category pivoted
Multiple categories (with one pivoted)
Data elements with different category combos
Notes about implementation
As an general approach, I aimed to decouple the display details (table, rows, columns, column and row spans) from our internal concepts (data elements, categories, category options, cocs etc...), to provide a middle layer (a matrix) that represents a form in our context. This middle layer can become the base of a form builder, for implementations that are cross-platform and other improvements in the future.
With the previous implementation, we were more than half-way there, but the data elements were tightly coupled to rows, and in turn the rows/data elements are tightly coupled to functionality like search, filters, highlighting current cell in the table etc... The next step should be to consolidate this implementation with the "normal" section form - there is a followup ticket for this: https://dhis2.atlassian.net/browse/LIBS-584
The only concept that remains metadata-aware is the
date entry field
- this was the existing design and it works well, as a self-contained component responsible of its own state, validation etc... regardless of where it appears in a form.I avoided changing the original
CategoryComboTable
and added a newPivotedCategoryComboTable
to handle the new use cases for transposing. I didn't want to change something that already works and well-tested for what's essentially an experimental new feature (i.e. not part of achieving parity with the existing app). Next step is to consolidate theses two components and the underlying matrix generation.In the grouped matrix logic, I added a special case for when there is one category and another for 1+ categories. This is needed because we need a "shadow" row in the case of more categories, this is unnecessary for one category. See the photo below, the first one has a "shadow" row (location fixed/outreach) and the categories are displayed underneath each other - this is necessary for multiple categories. In the case of one category (second table), we can do with the category being on top of the options.
Background
We are aiming to add more form configuration options as part of an initiative to provide configurations natively to data entry forms to reduce the necessity for custom forms. Users are currently building custom forms as a workaround for shortcomings of the configuration options (ability to transpose, or customise a cell design) or implementation (such to avoid issues with RTL issues). This is an RFC that describes the approach and the priorities for form configuration options. This is based on a thorough investigation by the functional design team for custom form use cases in real-life implementations. Based on that investigation, the ability to transpose forms and adding free-text descriptions were one of the main reasons people choose to go the custom forms route so we're tackling these first.
Known limitations
ToDos (future)
Related PRs: