Skip to content
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-16262] Support Custom Layout for Enrollment Pages #3481

Merged

Conversation

eirikhaugstulen
Copy link
Contributor

@eirikhaugstulen eirikhaugstulen commented Dec 7, 2023

Support building a custom enrollment dashboard layout, using a custom config stored in the data store.
The system administrator should be able to design, reorder, hide and lock a dashboard for a program.

Overview

Each enrollment page has a separate key and config in the data store:

ENROLLMENT_OVERVIEW: 'enrollmentOverviewLayout',
ENROLLMENT_EVENT_NEW: 'enrollmentEventNewLayout',
ENROLLMENT_EVENT_EDIT: 'enrollmentEventEditLayout',

We will check this key for a custom page layout, or fallback to the default one stored under DefaultPageLayout in each page.

Some components will also have additional settings that can be overridden by the config.

// ProfileWidget
settings = {
    readOnlyMode: boolean
}

// EnrollmentWidget
settings = {
    readOnlyMode: boolean
}

Supported components

type DefaultComponents = 'QuickActions'
    | 'StagesAndEvents'
    | 'AssigneeWidget'
    | 'NewEventWorkspace'
    | 'EditEventWorkspace'
    | 'EnrollmentComment'
    | 'EventComment'
    | 'TrackedEntityRelationship'
    | 'ErrorWidget'
    | 'WarningWidget'
    | 'FeedbackWidget'
    | 'IndicatorWidget'
    | 'ProfileWidget'
    | 'EnrollmentWidget';

Examples

Custom config to build the default enrollment dashboard (Child Programme):

{
  "IpHINAT79UW": {
    "title": "Child Programme dashboard"
    "leftColumn": [
      {
        "type": "component",
        "name": "QuickActions"
      },
      {
        "type": "component",
        "name": "StagesAndEvents"
      }
    ],
    "rightColumn": [
      {
        "type": "component",
        "name": "TrackedEntityRelationship"
      },
      {
        "type": "component",
        "name": "ErrorWidget"
      },
      {
        "type": "component",
        "name": "WarningWidget"
      },
      {
        "type": "component",
        "name": "FeedbackWidget"
      },
      {
        "type": "component",
        "name": "IndicatorWidget"
      },
      {
        "type": "component",
        "name": "Notes"
      },
      {
        "type": "component",
        "name": "ProfileWidget",
        "settings": {
             "readOnlyMode": true
        }
      },
      {
        "type": "component",
        "name": "EnrollmentWidget",
         "settings": {
             "readOnlyMode": true
        }
      }
    ]
  }
}

Optional parameters

All parts of the config is optional. You can choose to:

  • Not have a title above the page
  • Only have one column for the full page
  • Place any component in any column (Given it's supported by the page)

Images

Example:
image

@eirikhaugstulen eirikhaugstulen marked this pull request as ready for review December 18, 2023 13:46
@eirikhaugstulen eirikhaugstulen requested a review from a team as a code owner December 18, 2023 13:46
Copy link
Contributor

@simonadomnisoru simonadomnisoru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on this feature 👏 ! The code is very well structured and easy to follow

const renderWidget = (widget: ColumnConfig, availableWidgets, props) => {
const { type } = widget;

if (type.toLowerCase() === WidgetTypes.COMPONENT) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to support other types of widgets in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! Yes, we will extend this config to also support Enrollment Dashboard plugins. 😊
https://dhis2.atlassian.net/browse/DHIS2-16305

Copy link

github-actions bot commented Jan 23, 2024

…_CustomEnrollmentOverviewSchema

# Conflicts:
#	i18n/en.pot
#	src/core_modules/capture-core/components/Pages/EnrollmentEditEvent/EnrollmentEditEventPage.component.js
#	src/core_modules/capture-core/components/Pages/EnrollmentEditEvent/EnrollmentEditEventPage.container.js
#	src/core_modules/capture-core/components/Pages/EnrollmentEditEvent/EnrollmentEditEventPage.types.js
#	src/core_modules/capture-core/components/WidgetEventEdit/WidgetEventEdit.container.js
#	src/core_modules/capture-core/components/WidgetEventEdit/widgetEventEdit.types.js
Copy link

@geethaalwan geethaalwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested successfully on 2.41,2.40.3,2.39.5,2.38.7 versions

@eirikhaugstulen eirikhaugstulen merged commit 9cc3d70 into master Feb 4, 2024
38 of 39 checks passed
@eirikhaugstulen eirikhaugstulen deleted the eh/feat/DHIS2-16262_CustomEnrollmentOverviewSchema branch February 4, 2024 08:24
dhis2-bot added a commit that referenced this pull request Feb 4, 2024
# [100.54.0](v100.53.1...v100.54.0) (2024-02-04)

### Features

* [DHIS2-16262] Support Custom Layout for Enrollment Pages ([#3481](#3481)) ([9cc3d70](9cc3d70))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 100.54.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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants