Skip to content

Commit

Permalink
feat: [DHIS2-15480] widget assignee (#3412)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonadomnisoru authored Jan 25, 2024
1 parent 12a571a commit d61efae
Show file tree
Hide file tree
Showing 60 changed files with 869 additions and 512 deletions.
52 changes: 52 additions & 0 deletions cypress/e2e/WidgetsForEnrollmentPages/WidgetAssignee/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';

When('you assign the user Geetha in the view mode', () => {
cy.get('[data-test="widget-assignee"]').within(() => {
cy.get('[data-test="widget-assignee-assign"]').click();
cy.get('[data-test="capture-ui-input"]').type('Geetha');
cy.contains('Geetha Alwan').click();
cy.get('[data-test="widget-assignee-save"]').click();
});
});

When('you assign the user Tracker demo User in the edit mode', () => {
cy
.get('[data-test="widget-enrollment-event"]')
.find('[data-test="dhis2-uicore-button"]')
.eq(1)
.click();

cy.get('[data-test="widget-assignee"]').within(() => {
cy.get('[data-test="widget-assignee-edit"]').click();
cy.get('[data-test="dhis2-uicore-chip-remove"]').click();
cy.get('[data-test="capture-ui-input"]').type('Tracker demo');
cy.contains('Tracker demo User').click();
cy.get('[data-test="widget-assignee-save"]').click();
});
});

When('you remove the assigned user', () => {
cy.get('[data-test="widget-assignee"]').within(() => {
cy.get('[data-test="widget-assignee-edit"]').click();
cy.get('[data-test="dhis2-uicore-chip-remove"]').click();
cy.get('[data-test="widget-assignee-save"]').click();
});
});

Then('the event has the user Geetha Alwan assigned', () => {
cy.get('[data-test="widget-assignee"]').within(() => {
cy.get('[data-test="widget-contents"]').contains('Geetha Alwan').should('exist');
});
});

Then('the event has the user Tracker demo User assigned', () => {
cy.get('[data-test="widget-assignee"]').within(() => {
cy.get('[data-test="widget-contents"]').contains('Tracker demo User').should('exist');
});
});

Then('the event has no assignd user', () => {
cy.get('[data-test="widget-assignee"]').within(() => {
cy.get('[data-test="widget-contents"]').contains('No one is assigned to this event').should('exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,13 @@ Feature: The user interacts with the widgets on the enrollment edit event
Given you land on the enrollment edit event page by having typed /#/enrollmentEventEdit?eventId=XGLkLlOXgmE&orgUnitId=DiszpKrYNg8
Then the enrollment widget should be loaded
When you click edit mode
Then list should contain the new comment: new test comment
Then list should contain the new comment: new test comment

Scenario: You can assign a user to a event
Given you land on the enrollment edit event page by having typed /#/enrollmentEventEdit?eventId=veuwiLC2x0e&orgUnitId=g8upMTyEZGZ
When you assign the user Geetha in the view mode
Then the event has the user Geetha Alwan assigned
When you assign the user Tracker demo User in the edit mode
Then the event has the user Tracker demo User assigned
When you remove the assigned user
Then the event has no assignd user
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ import '../sharedSteps';
import '../WidgetEnrollment';
import '../WidgetProfile';
import '../WidgetEventComment';
import '../WidgetAssignee';

52 changes: 29 additions & 23 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-01-05T14:09:35.742Z\n"
"PO-Revision-Date: 2024-01-05T14:09:35.742Z\n"
"POT-Creation-Date: 2024-01-22T13:52:51.172Z\n"
"PO-Revision-Date: 2024-01-22T13:52:51.172Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -802,18 +802,18 @@ msgstr "Program Stages could not be loaded"
msgid "Stage"
msgstr "Stage"

msgid "Enrollment{{escape}} View Event"
msgstr "Enrollment{{escape}} View Event"

msgid "Enrollment{{escape}} Edit Event"
msgstr "Enrollment{{escape}} Edit Event"

msgid "The enrollment event data could not be found"
msgstr "The enrollment event data could not be found"

msgid "There are no feedback for this event"
msgstr "There are no feedback for this event"

msgid "Enrollment{{escape}} View Event"
msgstr "Enrollment{{escape}} View Event"

msgid "Enrollment{{escape}} Edit Event"
msgstr "Enrollment{{escape}} Edit Event"

msgid "Registered events"
msgstr "Registered events"

Expand Down Expand Up @@ -926,15 +926,6 @@ msgstr ""
"Leaving this page will discard any selections you made for a new "
"relationship"

msgid "No one is assigned to this event"
msgstr "No one is assigned to this event"

msgid "Assign"
msgstr "Assign"

msgid "Event assigned to {{name}}"
msgstr "Event assigned to {{name}}"

msgid "Feedbacks"
msgstr "Feedbacks"

Expand Down Expand Up @@ -1107,6 +1098,24 @@ msgstr "To work with the selected program,"
msgid "open the Tracker Capture app"
msgstr "open the Tracker Capture app"

msgid "Assigned to"
msgstr "Assigned to"

msgid "You don't have access to edit this assignee"
msgstr "You don't have access to edit this assignee"

msgid "Edit"
msgstr "Edit"

msgid "No one is assigned to this event"
msgstr "No one is assigned to this event"

msgid "You don't have access to assign an assignee"
msgstr "You don't have access to assign an assignee"

msgid "Assign"
msgstr "Assign"

msgid "This program is protected"
msgstr "This program is protected"

Expand Down Expand Up @@ -1182,9 +1191,6 @@ msgstr "Latitude"
msgid "Longitude"
msgstr "Longitude"

msgid "Edit"
msgstr "Edit"

msgid "Set coordinates"
msgstr "Set coordinates"

Expand Down Expand Up @@ -1380,9 +1386,6 @@ msgstr "This stage can only have one event"
msgid "Events could not be retrieved. Please try again later."
msgstr "Events could not be retrieved. Please try again later."

msgid "Assigned to"
msgstr "Assigned to"

msgid "{{ totalEvents }} events"
msgstr "{{ totalEvents }} events"

Expand Down Expand Up @@ -1578,6 +1581,9 @@ msgstr "Error deleting the enrollment event"
msgid "Error editing the event, the changes made were not saved"
msgstr "Error editing the event, the changes made were not saved"

msgid "Error updating the Assignee"
msgstr "Error updating the Assignee"

msgid "Set coordinate"
msgstr "Set coordinate"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const getAddEventEnrollmentServerData = (state: ReduxState,
program: programId,
programStage: formFoundation.id,
orgUnit: orgUnitId,
trackedEntityInstance: teiId,
trackedEntity: teiId,
enrollment: enrollmentId,
...getApiCategoriesArgument(state.currentSelections.categories),
dataValues: Object
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
export { UserField } from './UserField.component';
export { UserSearch } from './UserSearch.component';
export type { User as UserFormField } from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const NewEventWorkspacePlain = ({
onSave={onSave}
onCancel={onCancel}
hideDueDate={stage?.hideDueDate}
enableUserAssignment
/>}
</div>
</Widget>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @flow

import { actionCreator } from '../../../actions/actions.utils';
import type { UserFormField } from '../../FormFields/UserField';

export const actionTypes = {
ASSIGNEE_SET: 'EnrollmentDomain.AssigneeSet',
ASSIGNEE_SAVE_FAILED: 'EnrollmentDomain.AssigneeSaveFailed',
};

export const setAssignee = (assignedUser?: ApiAssignedUser, assignee: UserFormField | null, eventId: string) =>
actionCreator(actionTypes.ASSIGNEE_SET)({ assignedUser, assignee, eventId });

export const rollbackAssignee = (assignedUser?: ApiAssignedUser, assignee: UserFormField | null, eventId: string) =>
actionCreator(actionTypes.ASSIGNEE_SAVE_FAILED)({ assignedUser, assignee, eventId });
Loading

0 comments on commit d61efae

Please sign in to comment.