Skip to content

Commit

Permalink
Merge pull request #263 from EyeSeeTea/development
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
adrianq authored Jul 24, 2020
2 parents fe9fb62 + 8073e69 commit 89d5191
Show file tree
Hide file tree
Showing 42 changed files with 10,930 additions and 5,054 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ install:
script:
- yarn wait-on http-get://localhost:8080
- curl -F [email protected] -X POST -u "$CYPRESS_DHIS2_AUTH" "http://localhost:8080/api/apps"
- CYPRESS_EXTERNAL_API=http://localhost:8080 CYPRESS_ROOT_URL=http://localhost:8080 xvfb-run --auto-servernum --server-num=1 --server-args="-screen 0 1024x768x24" yarn cy:e2e:run --browser chrome --record --key ae48c13f-96a1-4850-b8b2-d5329b3c4813
- CYPRESS_EXTERNAL_API=http://localhost:8080 CYPRESS_ROOT_URL=http://localhost:8080 yarn cy:e2e:run --record --key ae48c13f-96a1-4850-b8b2-d5329b3c4813
- kill $(jobs -p) || true
addons:
apt:
Expand Down
17 changes: 15 additions & 2 deletions cypress/integration/00.project-create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,20 @@ describe("Projects - Create", () => {

cy.contains("Next").click();

// Disaggregation

cy.waitForStep("Disaggregation");
cy.get("[data-cy=covid19-selector-B010200]")
.contains("No")
.click();
cy.get(".MuiPopover-paper")
.contains("Yes")
.click();
cy.contains("Next").click();

// Sharing

cy.waitForStep("Sharing");
cy.waitForStep("Username Access");
cy.contains("System Admin");
cy.contains("Project Monitoring Admin");
cy.contains("Country Admin Bahamas");
Expand Down Expand Up @@ -130,7 +141,9 @@ describe("Projects - Create", () => {
cy.contains("Agriculture");
cy.contains("Livelihood");

cy.contains("# of agriculture groups receiving support for improved livelihoods - B010200");
cy.contains(
"# of agriculture groups receiving support for improved livelihoods - B010200 [COVID-19]"
);
cy.contains("# of people trained in livelihood topics - P020100 [MER]");

cy.server()
Expand Down
34 changes: 17 additions & 17 deletions cypress/integration/02.target-values.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ describe("Target Values", () => {
cy.contains("Add Target Values").click();
});

it("can enter data values with new/recurring validations", () => {
it("can enter data values with new/returning validations", () => {
const entryPage = new DataEntryPage("data-entry");
entryPage.selectInput("WS8XV4WWPE7", "HllvX50cXC0", 10);
entryPage.selectInput("WS8XV4WWPE7", "GI9GyGCQwTf", 10);

const dataElementId = "e6wdrrz9ZS6";
const cocIds = {
maleNew: "nwv02VfyQuz",
maleRecurring: "rgEN46cGauU",
femaleNew: "UU2P0YSJM8A",
femaleRecurring: "xgT2W9JaXTq",
newMal: "TpxiQHEumCA",
returningMale: "SW9iYI4GmW2",
newFemale: "Oq364hCb4KD",
returningFemale: "ZbU1cop8Gzl",
};

entryPage.selectTab("Livelihood");
entryPage.selectInput(dataElementId, cocIds.maleNew, 1);
entryPage.selectInput(dataElementId, cocIds.maleRecurring, 0);
entryPage.selectInput(dataElementId, cocIds.femaleNew, 2);
entryPage.selectInput(dataElementId, cocIds.femaleRecurring, 0);
entryPage.selectInput(dataElementId, cocIds.newMal, 1);
entryPage.selectInput(dataElementId, cocIds.returningMale, 0);
entryPage.selectInput(dataElementId, cocIds.newFemale, 2);
entryPage.selectInput(dataElementId, cocIds.returningFemale, 0);

entryPage.selectMonth(1);

entryPage.selectTab("Livelihood");
entryPage.selectInput(dataElementId, cocIds.maleNew, 2);
entryPage.selectInput(dataElementId, cocIds.maleRecurring, 1);
entryPage.selectInput(dataElementId, cocIds.femaleNew, 3);
entryPage.selectInput(dataElementId, cocIds.femaleRecurring, 0);
entryPage.selectInput(dataElementId, cocIds.newMal, 2);
entryPage.selectInput(dataElementId, cocIds.returningMale, 1);
entryPage.selectInput(dataElementId, cocIds.newFemale, 3);
entryPage.selectInput(dataElementId, cocIds.returningFemale, 0);

entryPage.selectMonth(2);

entryPage.selectTab("Livelihood");
entryPage.selectInput(dataElementId, cocIds.maleNew, 3);
entryPage.selectInput(dataElementId, cocIds.maleRecurring, 4);
entryPage.hasValidationError("Recurring value (4) cannot be greater");
entryPage.selectInput(dataElementId, cocIds.newMal, 3);
entryPage.selectInput(dataElementId, cocIds.returningMale, 4);
entryPage.hasValidationError("Returning value (4) cannot be greater");
});
});
5 changes: 4 additions & 1 deletion cypress/integration/07.project-edit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ describe("Projects - Edit", () => {
cy.waitForStep("Selection of MER Indicators");
cy.contains("Next").click();

cy.waitForStep("Sharing");
cy.waitForStep("Disaggregation");
cy.contains("Next").click();

cy.waitForStep("Username Access");
cy.contains("Next").click();

cy.waitForStep("Summary and Save");
Expand Down
3 changes: 1 addition & 2 deletions cypress/integration/08.project-indicators.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ describe("Projects - Indicators", () => {
.expectSnackbar("Global data elements with selected subs cannot be unselected")

.selectSector("Protection")
// Select an indicator which has a paired sub indicator, its global should be also selected
.select("B100500")
.assertExactSelected(["B100500", "P100701", "P100700"])
.assertExactSelected(["B100500", "P100600"])

.selectSector("Nutrition")
// Select a cross-sectorial indicator which has paired sub indicators in other sectors (Food)
Expand Down
50 changes: 37 additions & 13 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: 2020-07-06T21:07:30.089Z\n"
"PO-Revision-Date: 2020-07-06T21:07:30.089Z\n"
"POT-Creation-Date: 2020-07-22T07:31:45.265Z\n"
"PO-Revision-Date: 2020-07-22T07:31:45.265Z\n"

msgid "Data Entry"
msgstr ""
Expand Down Expand Up @@ -104,6 +104,24 @@ msgstr ""
msgid "selected"
msgstr ""

msgid "No"
msgstr ""

msgid "Yes"
msgstr ""

msgid "Disaggregation"
msgstr ""

msgid "COVID-19"
msgstr ""

msgid "Add COVID-19 disaggregation"
msgstr ""

msgid "Remove COVID-19 disaggregation"
msgstr ""

msgid "Field should be a 5-digit number"
msgstr ""

Expand Down Expand Up @@ -180,12 +198,6 @@ msgid ""
"lost. Are you sure you want to proceed?"
msgstr ""

msgid "Yes"
msgstr ""

msgid "No"
msgstr ""

msgid "Data Approval"
msgstr ""

Expand Down Expand Up @@ -386,7 +398,7 @@ msgstr ""
msgid "New"
msgstr ""

msgid "Recurring"
msgid "Returning"
msgstr ""

msgid "Total Actual People"
Expand All @@ -398,10 +410,10 @@ msgstr ""
msgid "Female New"
msgstr ""

msgid "Male Recurring"
msgid "Male Returning"
msgstr ""

msgid "Female Recurring"
msgid "Female Returning"
msgstr ""

msgid "People"
Expand All @@ -428,6 +440,12 @@ msgstr ""
msgid "Global data elements with selected subs cannot be unselected"
msgstr ""

msgid "None"
msgstr ""

msgid "Unknown"
msgstr ""

msgid ""
"Actual value ({{actualValue}}) should not be greater than 20% of the target "
"value ({{targetValue}})"
Expand All @@ -437,7 +455,7 @@ msgid "there is no data for previous periods"
msgstr ""

msgid ""
"Recurring value ({{recurringValue}}) cannot be greater than the sum of new "
"Returning value ({{recurringValue}}) cannot be greater than the sum of new "
"values for past periods ({{newValuesSumFormula}})"
msgstr ""

Expand Down Expand Up @@ -546,7 +564,10 @@ msgstr ""
msgid "Selection of MER Indicators"
msgstr ""

msgid "Define sharing settings for metadata of the project."
msgid "Username Access"
msgstr ""

msgid "Define Sharing settings for project data."
msgstr ""

msgid "Summary and Save"
Expand Down Expand Up @@ -592,6 +613,9 @@ msgid ""
"Director and Regional Team."
msgstr ""

msgid "Override default disaggregation for project indicators"
msgstr ""

msgid ""
"If you need to correct an item in your project, please click the grey "
"“Previous” button located on the bottom right side of the screen."
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "project-monitoring-app",
"description": "DHIS2 Project Monitoring App",
"version": "0.3.1",
"version": "0.4.0",
"license": "GPL-3.0",
"author": "EyeSeeTea team",
"homepage": ".",
Expand All @@ -27,7 +27,7 @@
"d2": "^31.8.1",
"d2-api": "1.0.0",
"d2-manifest": "^1.0.0",
"d2-ui-components": "1.5.0",
"d2-ui-components": "1.6.0",
"exceljs": "^3.5.0",
"font-awesome": "^4.7.0",
"lodash": "^4.17.15",
Expand Down
5 changes: 3 additions & 2 deletions src/components/data-entry/DataEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ const DataEntry = (props: DataEntryProps) => {
<div style={styles.selector}>
{!state.dropdownHasValues && <Spinner isLoading={state.loading} />}
{state.dropdownHasValues && (
<div style={styles.dropdown} data-cy="month-selector">
<div style={styles.dropdown}>
<Dropdown
id="month-selector"
items={periodItems}
value={state.dropdownValue}
onChange={value => setState({ ...state, dropdownValue: value })}
Expand Down Expand Up @@ -244,7 +245,7 @@ const styles = {
backgroundIframe: { backgroundColor: "white" },
selector: { padding: "35px 10px 10px 5px", backgroundColor: "white" },
buttons: { display: "inline", marginLeft: 20 },
dropdown: { display: "inline" },
dropdown: { display: "inline-block" },
};

function isOptionInSelect(select: HTMLSelectElement, value: string): boolean {
Expand Down
23 changes: 17 additions & 6 deletions src/components/dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,33 @@ import DropdownForm from "./DropdownForm";

type Value = string;

interface DropdownProps {
items: Array<{ value: Value; text: string }>;
export type DropdownItem = { value: Value; text: string };

export interface DropdownProps {
id?: string;
items: Array<DropdownItem>;
onChange: (value: Value | undefined) => void;
label: string;
label?: string;
value?: Value;
hideEmpty?: boolean;
}

const Dropdown: React.FC<DropdownProps> = props => {
const { items, value, onChange, label, hideEmpty } = props;
const { items, value, onChange, label, hideEmpty, id } = props;
const selectValue =
value === undefined || !items.map(item => item.value).includes(value) ? "" : value;

const SelectWrapper = (props: any) =>
label ? (
<DropdownForm label={label}>{props.children}</DropdownForm>
) : (
<React.Fragment>{props.children}</React.Fragment>
);

return (
<DropdownForm label={label}>
<SelectWrapper>
<Select
data-cy={id}
value={selectValue}
onChange={ev => onChange((ev.target.value as string) || undefined)}
MenuProps={{
Expand All @@ -35,7 +46,7 @@ const Dropdown: React.FC<DropdownProps> = props => {
</MenuItem>
))}
</Select>
</DropdownForm>
</SelectWrapper>
);
};

Expand Down
25 changes: 25 additions & 0 deletions src/components/sections-sidebar/SectionsSidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import Sidebar, { SidebarProps, MenuItem } from "../steps/data-elements/Sidebar";
import { Id } from "../../types/d2-api";

interface SectionsSidebarProps {
sectorId: Id;
items: SidebarProps["menuItems"];
setSector(sectorItem: MenuItem): void;
}

const SectionsSidebar: React.FC<SectionsSidebarProps> = props => {
const { sectorId, items, setSector, children } = props;
return (
<Sidebar
menuItems={items}
currentMenuItemId={sectorId}
onMenuItemClick={setSector}
contents={<div style={styles.wrapper}>{children}</div>}
/>
);
};

const styles = { wrapper: { width: "100%" } };

export default SectionsSidebar;
15 changes: 15 additions & 0 deletions src/components/sections-sidebar/sections-sidebar-hooks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import Project from "../../models/Project";
import { Ref } from "../../types/d2-api";

export function useSectionsSidebar(project: Project) {
const items = React.useMemo(() => {
return project.sectors.map(sector => ({ id: sector.id, text: sector.displayName }));
}, [project]);

const [sectorId, setSectorId] = React.useState<string>(items.length > 0 ? items[0].id : "");

const setSector = React.useCallback((sector: Ref) => setSectorId(sector.id), [setSectorId]);

return { items, sectorId, setSector };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from "react";
import { StepProps } from "../../../pages/project-wizard/ProjectWizard";
import DataElementsStep, { DataElementsStepProps } from "../data-elements/DataElementsStep";

const DataElementsSelectionStep: React.FC<StepProps> = props => {
const { project } = props;
const getSelection: DataElementsStepProps["onSelect"] = React.useCallback(
(sectorId, dataElementIds) => {
return project.updateDataElementsSelection(sectorId, dataElementIds);
},
[project]
);

return (
<DataElementsStep
{...props}
onSelect={getSelection}
dataElementsSet={project.dataElementsSelection}
/>
);
};

export default React.memo(DataElementsSelectionStep);
Loading

0 comments on commit 89d5191

Please sign in to comment.