Skip to content

Commit

Permalink
feat: add assignee widget
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Jan 26, 2024
1 parent df59069 commit 94f92d6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import {
DefaultWidgetsForEnrollmentOverview,
EditEventWorkspace,
EventComment,
AssigneeWidget,
WidgetTypes,
} from '../../common/EnrollmentOverviewDomain/EnrollmentPageLayout';

export const WidgetsForEnrollmentEventEdit: $ReadOnly<{ [key: string]: WidgetConfig }> = Object.freeze({
EditEventWorkspace,
EventComment,
AssigneeWidget,
...DefaultWidgetsForEnrollmentOverview,
});

Expand All @@ -24,6 +26,10 @@ export const DefaultPageLayout: PageLayoutConfig = {
},
],
rightColumn: [
{
type: WidgetTypes.COMPONENT,
name: 'AssigneeWidget',
},
{
type: WidgetTypes.COMPONENT,
name: 'ErrorWidget',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { WidgetTypes } from './DefaultEnrollmentLayout.constants';

type DefaultComponents = 'QuickActions'
| 'StagesAndEvents'
| 'AssigneeWidget'
| 'NewEventWorkspace'
| 'EditEventWorkspace'
| 'EnrollmentComment'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type { WidgetConfig } from '../DefaultEnrollmentLayout.types';
import { NewEventWorkspaceWrapper } from '../../../NewEventWorkspaceWrapper';
import { WidgetEventEditWrapper } from '../../../WidgetEventEditWrapper';
import { WidgetEventComment } from '../../../../../WidgetEventComment';
import { WidgetAssignee } from '../../../../../WidgetAssignee';

export const QuickActions: WidgetConfig = {
Component: EnrollmentQuickActions,
Expand Down Expand Up @@ -183,6 +184,7 @@ export const EditEventWorkspace: WidgetConfig = {
onCancelEditEvent,
onHandleScheduleSave,
initialScheduleDate,
assignee,
}) => ({
programStage,
onGoBack,
Expand All @@ -194,6 +196,26 @@ export const EditEventWorkspace: WidgetConfig = {
onCancelEditEvent,
onHandleScheduleSave,
initialScheduleDate,
assignee,
}),
};

export const AssigneeWidget: WidgetConfig = {
Component: WidgetAssignee,
getProps: ({
programStage,
assignee,
getAssignedUserSaveContext,
eventAccess,
onSaveAssignee,
onSaveAssigneeError,
}) => ({
enabled: programStage?.enableUserAssignment || false,
assignee,
getSaveContext: getAssignedUserSaveContext,
writeAccess: eventAccess?.write || false,
onSave: onSaveAssignee,
onSaveError: onSaveAssigneeError,
}),
};

Expand Down

0 comments on commit 94f92d6

Please sign in to comment.