Skip to content

Commit

Permalink
feat: [DHIS2-15238] show and filter on assigned user in program stage…
Browse files Browse the repository at this point in the history
… WL (#3821)
  • Loading branch information
simonadomnisoru authored Oct 9, 2024
1 parent 640067d commit e032d50
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
import '../../sharedSteps';
import '../sharedSteps';

beforeEach(() => {
// Disable cache for chromium browsers to force the api to be called
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
import { v4 as uuid } from 'uuid';
import '../../sharedSteps';
import '../sharedSteps';
import { getCurrentYear, combineDataAndYear } from '../../../../support/date';

Given('you open the main page with Ngelehun and malaria case context', () => {
Expand Down
18 changes: 18 additions & 0 deletions cypress/e2e/WorkingLists/EventWorkingLists/sharedSteps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';
import '../sharedSteps';

When('you set the assignee filter to anyone', () => {
cy.get('[data-test="event-working-lists"]')
.contains('Assigned to')
.click();

cy.get('[data-test="list-view-filter-contents"]')
.contains('Anyone')
.click();
});

Then('the assigned to filter button should show that the anyone filter is in effect', () => {
cy.get('[data-test="event-working-lists"]')
.contains('Assigned to: Anyone')
.should('exist');
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Scenario: Show only teis with active enrollments and unassinged events using the
Given you open the main page with Ngelehun and Malaria focus investigation context
When you set the enrollment status filter to active
And you apply the enrollment status filter
And you set the assginee filter to none
And you set the assginee filter to None
And you apply the assignee filter
Then the enrollment status filter button should show that the active filter is in effect
And the assignee filter button should show that unassigned filter is in effect
And the assignee filter button should show that None filter is in effect
And teis with active enrollments and unassigned events should be retrieved from the api
And the list should display the teis retrieved from the api
And for a tracker program the page navigation should show that you are on the first page
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
import '../../sharedSteps';
import '../sharedSteps';

beforeEach(() => {
// Disable cache for chromium browsers to force the api to be called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ Scenario: Show only teis with active enrollments and unassinged events using the
Given you open the main page with Ngelehun and Malaria focus investigation context
When you set the enrollment status filter to active
And you apply the current filter
And you set the assginee filter to none
And you set the assginee filter to None
And you apply the current filter
Then the enrollment status filter button should show that the active filter is in effect
And the assignee filter button should show that unassigned filter is in effect
And the assignee filter button should show that None filter is in effect
And the list should display teis with an active enrollment and unassinged events
And rows per page should be set to 15
And for a tracker program the page navigation should show that you are on the first page
Expand Down Expand Up @@ -201,6 +201,40 @@ And you set the event visit date to Today
And you apply the current filter
Then the working list is empty

Scenario: The user can filter the Foci response assigned events
Given you open the main page with Ngelehun and Malaria focus investigation context
When you open the program stage filters from the more filters dropdown menu
And you select the Foci response program stage
And you apply the current filter
And you set the assginee filter to Anyone
And you apply the current filter
Then the assignee filter button should show that Anyone filter is in effect
And the assignee column is displayed

Scenario: The assigned user data is kept when switching between working list types
Given you open the main page with Ngelehun and Malaria focus investigation context
And you filter by assigned Foci investigation & classification events
And the assignee filter button should show that Anyone filter is in effect
When you remove the program stage filter
Then you don't see program stage working list events
And the assignee filter button should show that Anyone filter is in effect
When you set the assginee filter to None
And you apply the current filter
Then the assignee filter button should show that None filter is in effect
When you open the program stage filters from the more filters dropdown menu
And you select the Foci response program stage
And you apply the current filter
Then the assignee filter button should show that None filter is in effect

@v>=40
Scenario: The user can create and delete a program stage working list for Foci investigation & classification assigned events
Given you open the main page with Ngelehun and Malaria focus investigation context
And you filter by assigned Foci investigation & classification events
When you save the list with the name Custom Program stage list
Then the new Custom Program stage list is created
And you delete the name Custom Program stage list
Then the Custom Program stage list is deleted

@v>=40
Scenario: The user creates, updates and deletes a Program stage custom working list
Given you open the main page with Ngelehun and Malaria case diagnosis and Household investigation context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Given, When, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import { v4 as uuid } from 'uuid';
import '../../sharedSteps';
import '../sharedSteps';

const cleanUpIfApplicable = (programId) => {
cy.buildApiUrl(`programStageWorkingLists?filter=program.id:eq:${programId}&fields=id,displayName`)
Expand Down Expand Up @@ -198,22 +198,6 @@ When('you set the WHOMCH Smoking filter to No', () => {
.click();
});

When('you set the assginee filter to none', () => {
cy.get('[data-test="tei-working-lists"]')
.contains('Assigned to')
.click();

cy.get('[data-test="list-view-filter-contents"]')
.contains('None')
.click();
});

Then('the assignee filter button should show that unassigned filter is in effect', () => {
cy.get('[data-test="tei-working-lists"]')
.contains('Assigned to: None')
.should('exist');
});

Then('the list should display teis with an active enrollment and unassinged events', () => {
const ids = [
'ZDA984904',
Expand Down Expand Up @@ -627,7 +611,7 @@ When('you select a data element columns and save from the column selector', () =
});

Then('you see data elements specific filters and columns', () => {
cy.get('[data-test="filter-button-container-DX4LVYeP7bw"]')
cy.get('[data-test="filter-button-container-assignee"]')
.should('exist');
cy.get('[data-test="tei-working-lists"]')
.should('exist');
Expand Down Expand Up @@ -866,3 +850,46 @@ Then('the working list is empty', () => {
.contains('No items to display')
.click();
});

Then('the assignee column is displayed', () => {
cy.get('[data-test="dhis2-uicore-tablehead"]')
.contains('Assigned to')
.should('exist');

cy.get('[data-test="dhis2-uicore-tablebody"]')
.contains('Tracker demo User (tracker)')
.should('exist');

cy.get('[data-test="tei-working-lists"]')
.find('tr')
.should('have.length', 2);
});

And('you filter by assigned Foci investigation & classification events', () => {
cy.get('[data-test="tei-working-lists"]')
.within(() => {
cy.contains('More filters')
.click();
});

cy.get('[data-test="more-filters-menu"]')
.within(() => cy.contains('Program stage').click());

cy.get('[data-test="list-view-filter-contents"]')
.contains('Foci investigation & classification')
.click();

cy.get('[data-test="list-view-filter-apply-button"]')
.click();

cy.get('[data-test="tei-working-lists"]')
.contains('Assigned to')
.click();

cy.get('[data-test="list-view-filter-contents"]')
.contains('Anyone')
.click();

cy.get('[data-test="list-view-filter-apply-button"]')
.click();
});
18 changes: 18 additions & 0 deletions cypress/e2e/WorkingLists/TeiWorkingLists/sharedSteps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';
import '../sharedSteps';

When(/^you set the assginee filter to (.*)$/, (assignedUser) => {
cy.get('[data-test="tei-working-lists"]')
.contains('Assigned to')
.click();

cy.get('[data-test="list-view-filter-contents"]')
.contains(assignedUser)
.click();
});

Then(/^the assignee filter button should show that (.*) filter is in effect/, (assignedUser) => {
cy.get('[data-test="tei-working-lists"]')
.contains(`Assigned to: ${assignedUser}`)
.should('exist');
});
32 changes: 0 additions & 32 deletions cypress/e2e/WorkingLists/sharedSteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,6 @@ Then('for a tracker program the page navigation should show that you are on the
.should('exist');
});

Then('the assigned to filter button should show that the anyone filter is in effect', () => {
cy.get('[data-test="event-working-lists"]')
.contains('Assigned to: Anyone')
.should('exist');
});

When('you set the assignee filter to anyone', () => {
cy.get('[data-test="event-working-lists"]')
.contains('Assigned to')
.click();

cy.get('[data-test="list-view-filter-contents"]')
.contains('Anyone')
.click();
});

When('you set the status filter to active', () => {
cy.get('[data-test="event-working-lists"]')
.contains('Status')
Expand Down Expand Up @@ -98,16 +82,6 @@ When('you set the enrollment status filter to active', () => {
.click();
});

When('you set the assginee filter to none', () => {
cy.get('[data-test="tei-working-lists"]')
.contains('Assigned to')
.click();

cy.get('[data-test="list-view-filter-contents"]')
.contains('None')
.click();
});

When(/^you set the first name filter to (.*)$/, (name) => {
cy.get('[data-test="tei-working-lists"]')
.contains('First name')
Expand Down Expand Up @@ -147,12 +121,6 @@ Then('rows per page should be set to 15', () => {
.should('exist');
});

Then('the assignee filter button should show that unassigned filter is in effect', () => {
cy.get('[data-test="tei-working-lists"]')
.contains('Assigned to: None')
.should('exist');
});

When('you change rows per page to 10', () => {
cy.get('div[data-test="rows-per-page-selector"]')
.click()
Expand Down
4 changes: 2 additions & 2 deletions docs/user/using-the-capture-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ Events can be assigned to users. This feature must be enabled per program.

5. Search for and select the user you would like to reassign the event to. Click the **Save** button.

### Assignee in the event list { #capture_user_assignment_event_list }
### Assignee in the event list

In the event list you will be able to view the assignee per event. Moreover, you can sort and filter the list by the assignee.

Expand Down Expand Up @@ -804,7 +804,7 @@ You can show data elements from a single stage in a working list. Select the "Pr

![](resources/images/program_stage_working_list.png)

The tracker program stage list can be [filtered](#filter-the-list), [sorted](#sort-the-list), [modified](#modify-the-list-layout), [saved](#capture_view_save), [updated](#capture_view_update), [deleted](#capture_view_delete) and [shared](#capture_view_share) in the same way as other working lists.
The tracker program stage list can be [filtered](#filter-the-list), [sorted](#sort-the-list), [modified](#modify-the-list-layout), [saved](#capture_view_save), [updated](#capture_view_update), [deleted](#capture_view_delete) and [shared](#capture_view_share) in the same way as other working lists. Additionally, the program stage list can be [filtered by assignee](#assignee-in-the-event-list), just like an event program list.

## Implementer / administrator info { #implementer_info }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const TeiWorkingListsSetup = ({
const prevTemplateId = useRef(currentTemplateId);
const defaultColumns = useDefaultColumnConfig(program, orgUnitId, programStageId);
const columns = useColumns<TeiWorkingListsColumnConfigs>(customColumnOrder, defaultColumns);
const filtersOnly = useFiltersOnly(program);
const filtersOnly = useFiltersOnly(program, programStageId);
const programStageFiltersOnly = useProgramStageFilters(program, programStageId);
const staticTemplates = useStaticTemplates(
storedTemplates?.find(storedTemplate => storedTemplate.isDefault && storedTemplate.isAltered),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,38 @@ const getProgramStageMainConfig = (programStage): Array<MetadataColumnConfig> =>
[
{
id: ADDITIONAL_FILTERS.status,
visible: false,
visible: true,
type: dataElementTypes.TEXT,
header: i18n.t(ADDITIONAL_FILTERS_LABELS.status),
},
{
id: ADDITIONAL_FILTERS.occurredAt,
visible: false,
visible: true,
type: dataElementTypes.DATE,
header: programStage.stageForm.getLabel('occurredAt') || i18n.t(ADDITIONAL_FILTERS_LABELS.occurredAt),
},
...(programStage.hideDueDate === false
? [
{
id: ADDITIONAL_FILTERS.scheduledAt,
visible: false,
visible: true,
type: dataElementTypes.DATE,
header:
programStage.stageForm.getLabel('scheduledAt') ||
i18n.t(ADDITIONAL_FILTERS_LABELS.scheduledAt),
},
]
: []),
...(programStage.enableUserAssignment
? [
{
id: ADDITIONAL_FILTERS.assignedUser,
visible: true,
type: dataElementTypes.ASSIGNEE,
header: i18n.t(ADDITIONAL_FILTERS_LABELS.assignee),
},
]
: []),
].map(field => ({
...field,
mainProperty: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import i18n from '@dhis2/d2-i18n';
import { dataElementTypes, type TrackerProgram } from '../../../../../metaData';
import { MAIN_FILTERS } from '../../constants';

export const useFiltersOnly = ({
enrollment: { enrollmentDateLabel, incidentDateLabel, showIncidentDate },
stages,
}: TrackerProgram) =>
export const useFiltersOnly = (
{ enrollment: { enrollmentDateLabel, incidentDateLabel, showIncidentDate }, stages }: TrackerProgram,
programStageId?: string,
) =>
useMemo(() => {
const enableUserAssignment = Array.from(stages.values()).find(stage => stage.enableUserAssignment);
const enableUserAssignment =
!programStageId && Array.from(stages.values()).find(stage => stage.enableUserAssignment);
return [
{
id: MAIN_FILTERS.PROGRAM_STATUS,
Expand Down Expand Up @@ -80,9 +81,15 @@ export const useFiltersOnly = ({
id: MAIN_FILTERS.ASSIGNEE,
type: dataElementTypes.ASSIGNEE,
header: i18n.t('Assigned to'),
transformRecordsFilter: (rawFilter: Object) => rawFilter,
transformRecordsFilter: (rawFilter: Object) => {
const { assignedUser, assignedUserMode } = rawFilter;
return {
assignedUserMode,
...(assignedUser && { assignedUser }),
};
},
},
]
: []),
];
}, [enrollmentDateLabel, incidentDateLabel, showIncidentDate, stages]);
}, [enrollmentDateLabel, incidentDateLabel, showIncidentDate, stages, programStageId]);
Loading

0 comments on commit e032d50

Please sign in to comment.