Skip to content

Commit

Permalink
Show button to edit cases data only when user defined
Browse files Browse the repository at this point in the history
  • Loading branch information
anagperal committed Dec 23, 2024
1 parent 54c7957 commit 63fb32b
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 22 deletions.
16 changes: 13 additions & 3 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-12-19T16:37:02.900Z\n"
"PO-Revision-Date: 2024-12-19T16:37:02.900Z\n"
"POT-Creation-Date: 2024-12-23T12:07:43.318Z\n"
"PO-Revision-Date: 2024-12-23T12:07:43.318Z\n"

msgid "Low"
msgstr ""
Expand Down Expand Up @@ -87,6 +87,9 @@ msgstr ""
msgid "Edit Details"
msgstr ""

msgid "Edit historical case data"
msgstr ""

msgid "Complete Event"
msgstr ""

Expand All @@ -108,7 +111,7 @@ msgstr ""
msgid "Select a file"
msgstr ""

msgid "Errors in cases data file"
msgid "Errors in file"
msgstr ""

msgid "Close"
Expand Down Expand Up @@ -230,6 +233,9 @@ msgstr ""
msgid "Disease Outbreak saved successfully"
msgstr ""

msgid "Disease outbreak case data saved successfully"
msgstr ""

msgid "Warning"
msgstr ""

Expand Down Expand Up @@ -301,3 +307,7 @@ msgstr ""

msgid "Resources"
msgstr ""

msgctxt "DATA"
msgid "HISTORICAL_CASE"
msgstr ""
14 changes: 12 additions & 2 deletions i18n/es.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2024-12-19T16:37:02.900Z\n"
"POT-Creation-Date: 2024-12-23T12:07:43.318Z\n"
"PO-Revision-Date: 2018-10-25T09:02:35.143Z\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -86,6 +86,9 @@ msgstr ""
msgid "Edit Details"
msgstr ""

msgid "Edit historical case data"
msgstr ""

msgid "Complete Event"
msgstr ""

Expand All @@ -107,7 +110,7 @@ msgstr ""
msgid "Select a file"
msgstr ""

msgid "Errors in cases data file"
msgid "Errors in file"
msgstr ""

msgid "Close"
Expand Down Expand Up @@ -229,6 +232,9 @@ msgstr ""
msgid "Disease Outbreak saved successfully"
msgstr ""

msgid "Disease outbreak case data saved successfully"
msgstr ""

msgid "Warning"
msgstr ""

Expand Down Expand Up @@ -301,6 +307,10 @@ msgstr ""
msgid "Resources"
msgstr ""

msgctxt "DATA"
msgid "HISTORICAL_CASE"
msgstr ""

#~ msgid "Add"
#~ msgstr "Añadir"

Expand Down
16 changes: 15 additions & 1 deletion src/domain/usecases/GetConfigurableFormUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { Maybe } from "../../utils/ts-utils";
import { FormType } from "../../webapp/pages/form-page/FormPage";
import { Configurations } from "../entities/AppConfigurations";
import { ConfigurableForm } from "../entities/ConfigurableForm";
import { DiseaseOutbreakEvent } from "../entities/disease-outbreak-event/DiseaseOutbreakEvent";
import {
CasesDataSource,
DiseaseOutbreakEvent,
} from "../entities/disease-outbreak-event/DiseaseOutbreakEvent";
import { Future } from "../entities/generic/Future";
import { Id } from "../entities/Ref";
import { CasesFileRepository } from "../repositories/CasesFileRepository";
Expand Down Expand Up @@ -47,6 +50,17 @@ export class GetConfigurableFormUseCase {
switch (formType) {
case "disease-outbreak-event":
case "disease-outbreak-event-case-data": {
if (
formType === "disease-outbreak-event-case-data" &&
(id !== eventTrackerDetails?.id ||
eventTrackerDetails?.casesDataSource !==
CasesDataSource.RTSL_ZEB_OS_CASE_DATA_SOURCE_USER_DEF)
) {
return Future.error(
new Error("Cases data source in disease outbreak is not user defined.")
);
}

return getDiseaseOutbreakConfigurableForm(
this.options,
configurations,
Expand Down
1 change: 1 addition & 0 deletions src/webapp/components/form/FieldWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const FieldWidget: React.FC<FieldWidgetProps> = React.memo((props): JSX.E
onChange={notifyChange}
fileTemplate={field.fileTemplate}
fileId={field.fileId}
fileNameLabel={field.fileNameLabel}
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/webapp/components/form/FormFieldsState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export type FormFileFieldState = FormFieldStateBase<Maybe<File>> & {
data: Maybe<SheetData[]>;
fileId: Maybe<Id>;
fileTemplate: Maybe<File>;
fileNameLabel?: string;
};

export type AddNewFieldState = FormFieldStateBase<null> & {
Expand Down
37 changes: 24 additions & 13 deletions src/webapp/components/form/form-summary/EventTrackerFormSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type EventTrackerFormSummaryProps = {
formSummary: Maybe<FormSummaryData>;
globalMessage: Maybe<GlobalMessage>;
onCompleteClick: () => void;
isCasesDataUserDefined?: boolean;
};

const ROW_COUNT = 3;
Expand All @@ -35,6 +36,7 @@ export const EventTrackerFormSummary: React.FC<EventTrackerFormSummaryProps> = R
formSummary,
onCompleteClick,
globalMessage,
isCasesDataUserDefined = false,
} = props;
const { goTo } = useRoutes();
const snackbar = useSnackbar();
Expand Down Expand Up @@ -64,14 +66,18 @@ export const EventTrackerFormSummary: React.FC<EventTrackerFormSummaryProps> = R
>
{i18n.t("Edit Details")}
</Button>
<Button
variant="outlined"
color="secondary"
onClick={onEditCaseDataClick}
startIcon={<BackupIcon />}
>
{i18n.t("Edit historical case data")}
</Button>

{isCasesDataUserDefined ? (
<Button
variant="outlined"
color="secondary"
onClick={onEditCaseDataClick}
startIcon={<BackupIcon />}
>
{i18n.t("Edit historical case data")}
</Button>
) : null}

<Button
variant="outlined"
color="secondary"
Expand Down Expand Up @@ -102,12 +108,12 @@ export const EventTrackerFormSummary: React.FC<EventTrackerFormSummaryProps> = R
headerButtons={headerButtons}
titleVariant="secondary"
>
<IncidentManagerContainer>
{formSummary.incidentManager && (
<UserCard selectedUser={formSummary.incidentManager} />
)}
</IncidentManagerContainer>
<SummaryContainer>
<SummaryColumn>
{formSummary.incidentManager && (
<UserCard selectedUser={formSummary.incidentManager} />
)}
</SummaryColumn>
<SummaryColumn>
{formSummary.summary.map((labelWithValue, index) =>
index < ROW_COUNT
Expand Down Expand Up @@ -162,6 +168,11 @@ const SummaryColumn = styled.div`
`;

const StyledType = styled(Typography)`
margin-block-start: 10px;
color: ${props => props.theme.palette.text.hint};
white-space: pre-line;
`;

const IncidentManagerContainer = styled.div`
margin-block-end: 10px;
`;
6 changes: 4 additions & 2 deletions src/webapp/components/import-file/ImportFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type ImportFileProps = {
errorText?: string;
error?: boolean;
required?: boolean;
fileNameLabel?: string;
};

export const ImportFile: React.FC<ImportFileProps> = React.memo(props => {
Expand All @@ -43,6 +44,7 @@ export const ImportFile: React.FC<ImportFileProps> = React.memo(props => {
required,
fileTemplate,
fileId,
fileNameLabel,
} = props;

const snackbar = useSnackbar();
Expand Down Expand Up @@ -118,7 +120,7 @@ export const ImportFile: React.FC<ImportFileProps> = React.memo(props => {
<SimpleModal
open={openErrorsModal}
onClose={() => setOpenErrorsModal(false)}
title={i18n.t("Errors in cases data file")}
title={i18n.t("Errors in file")}
closeLabel={i18n.t("Close")}
>
{openErrorsModal && <ErrorsText>{errorText}</ErrorsText>}
Expand Down Expand Up @@ -146,7 +148,7 @@ export const ImportFile: React.FC<ImportFileProps> = React.memo(props => {
/>
<Link
href={URL.createObjectURL(file)}
download={fileId ? "HISTORICAL_CASE_DATA" : file.name}
download={fileId && fileNameLabel ? fileNameLabel : file.name}
underline="hover"
>
{fileId ? i18n.t("Download historical data") : file.name}
Expand Down
5 changes: 5 additions & 0 deletions src/webapp/components/section/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ const SectionContainer = styled.section<{ $hasSeparator?: boolean }>`
const Header = styled.div`
display: flex;
justify-content: space-between;
@media (max-width: 700px) {
flex-direction: column;
align-items: flex-start;
gap: 24px;
}
`;

const TitleContainer = styled.div`
Expand Down
6 changes: 5 additions & 1 deletion src/webapp/pages/event-tracker/EventTrackerPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { StatsCard } from "../../components/stats-card/StatsCard";
import { useLastAnalyticsRuntime } from "../../hooks/useLastAnalyticsRuntime";
import { useOverviewCards } from "./useOverviewCards";
import { SimpleModal } from "../../components/simple-modal/SimpleModal";
import { CasesDataSource } from "../../../domain/entities/disease-outbreak-event/DiseaseOutbreakEvent";

//TO DO : Create Risk assessment section
export const riskAssessmentColumns: TableColumn[] = [
Expand Down Expand Up @@ -83,7 +84,6 @@ export const EventTrackerPage: React.FC = React.memo(() => {
changeCurrentEventTracker(eventTrackerDetails);
}
}, [changeCurrentEventTracker, eventTrackerDetails]);

return (
<Layout title={i18n.t("Event Tracker")} lastAnalyticsRuntime={lastAnalyticsRuntime}>
<EventTrackerFormSummary
Expand All @@ -93,6 +93,10 @@ export const EventTrackerPage: React.FC = React.memo(() => {
formSummary={formSummary}
onCompleteClick={onOpenCompleteModal}
globalMessage={globalMessage}
isCasesDataUserDefined={
currentEventTracker?.casesDataSource ===
CasesDataSource.RTSL_ZEB_OS_CASE_DATA_SOURCE_USER_DEF
}
/>
<Section title={i18n.t("Districts Affected")} titleVariant="secondary" hasSeparator>
<DurationFilterContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ function getInitialFormStateForDiseaseOutbreakEvent(
data: undefined,
fileId: isCasesDataUserDefined ? uploadedCasesDataFileId : undefined,
fileTemplate: caseDataFileTemplete,
fileNameLabel:
isCasesDataUserDefined && uploadedCasesDataFileId
? i18n.t("HISTORICAL_CASE_DATA")
: undefined,
helperText:
editMode && isCasesDataUserDefined
? i18n.t(
Expand Down Expand Up @@ -782,6 +786,10 @@ function getInitialFormStateForDiseaseOutbreakCaseData(
data: undefined,
fileId: uploadedCasesDataFileId,
fileTemplate: caseDataFileTemplete,
fileNameLabel: uploadedCasesDataFileId
? i18n.t("HISTORICAL_CASE_DATA")
: undefined,

helperText: i18n.t(
"In order to add or replace cases, you need to download the current file and add the new ones."
),
Expand Down

0 comments on commit 63fb32b

Please sign in to comment.