Skip to content

Commit

Permalink
- improve lao translation.
Browse files Browse the repository at this point in the history
- display confirm dialog before convert to test and promote to case.
  • Loading branch information
pphetra committed Nov 7, 2023
1 parent 8691459 commit a25f1a9
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 23 deletions.
5 changes: 4 additions & 1 deletion components/case/caseLink.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import Link from "next/link";
import React from "react";
import { useTranslation } from "react-i18next";

type CaseLinkProps = {
caseId?: string;
};
const CaseLink: React.FC<CaseLinkProps> = ({ caseId }) => {
const { t } = useTranslation();

if (caseId == undefined) {
return null;
}
return (
<Link href={`/cases/${caseId}`}>
<div className="bg-red-500 text-white text-center rounded cursor-pointer px-2 hover:bg-red-600">
Case
{t("status.case", "Case")}
</div>
</Link>
);
Expand Down
2 changes: 1 addition & 1 deletion components/report/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const ReportList = () => {
{
label: "",
get: record => (
<div className="flex flex-row">
<div className="flex flex-row gap-1">
<CaseLink caseId={record.caseId} />
<TestLabel isTest={record.testFlag || false} />
</div>
Expand Down
58 changes: 44 additions & 14 deletions components/report/report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Spinner from "components/widgets/spinner";
import { useRouter } from "next/router";
import CaseLink from "components/case/caseLink";
import { RenderData, TR } from "components/widgets/renderData";
import ConfirmDialog from "components/widgets/dialogs/confirmDialog";
import dynamic from "next/dynamic";
import Comments from "components/widgets/comments";
import GalleryDialog from "components/widgets/dialogs/galleryDialog";
Expand Down Expand Up @@ -135,14 +136,16 @@ const Report = (props: { id: string }) => {
const { t } = useTranslation();

useEffect(() => {
setViewModel(
new ReportViewModel(
id as string,
services.reportService,
services.caseService,
services.outbreakService
)
const model = new ReportViewModel(
id as string,
services.reportService,
services.caseService,
services.outbreakService
);
model.registerDialog("confirmToTest");
model.registerDialog("confirmToPromoteToCase");

setViewModel(model);
}, [setViewModel, id, services]);

if (viewModel === undefined) {
Expand All @@ -166,25 +169,29 @@ const Report = (props: { id: string }) => {
<PromoteToCaseButton
disabled={viewModel.isLoading}
type="button"
onClick={async () => {
const caseId = await viewModel.promoteToCase();
if (caseId) router.push(`/cases/${caseId}`);
}}
onClick={() =>
viewModel.dialog("confirmToPromoteToCase")?.open(null)
}
>
{viewModel.isLoading && <Spinner />}
&nbsp;Promote To Case
&nbsp;
{t("status.actions.promoteToCase", "Promote to case")}
</PromoteToCaseButton>
)}
{viewModel.shouldDisplayConvertToTestReport && (
<ConvertToTestReportButton
disabled={viewModel.converting}
type="button"
onClick={async () => {
await viewModel.convertToTestReport();
viewModel.dialog("confirmToTest")?.open(null);
}}
>
{viewModel.converting && <Spinner />}
&nbsp;Convert to Test Report
&nbsp;
{t(
"status.actions.convertToTest",
"Convert to test report"
)}
</ConvertToTestReportButton>
)}
</div>
Expand Down Expand Up @@ -230,6 +237,29 @@ const Report = (props: { id: string }) => {
</div>
</div>

<ConfirmDialog
store={viewModel.dialog("confirmToTest")}
content={t(
"dialog.content.confirmConvertToTest",
"Would you like to convert this report to test report?.?"
)}
onYes={() => viewModel.convertToTestReport()}
onNo={() => viewModel.dialog("confirmDelete")?.close()}
/>

<ConfirmDialog
store={viewModel.dialog("confirmToPromoteToCase")}
content={t(
"dialog.content.confirmToPromoteToCase",
"Would you like to promote this report to case?.?"
)}
onYes={async () => {
const caseId = await viewModel.promoteToCase();
if (caseId) router.push(`/cases/${caseId}`);
}}
onNo={() => viewModel.dialog("confirmToPromoteToCase")?.close()}
/>

<ReportImage viewModel={viewModel} />

<Divide />
Expand Down
2 changes: 1 addition & 1 deletion components/report/reportViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class ReportViewModel extends BaseViewModel {
}

get shouldDisplayConvertToTestReport() {
return this.data.testFlag == false && this.data.caseId == null;
return this.data.testFlag == false;
}

get shouldDisplayPromoteToCase() {
Expand Down
12 changes: 11 additions & 1 deletion i18n/translations.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@
"confirmDelete": "Confirm Delete",
"confirmPublishReportType": "Publish this report to mobile application.",
"confirmUnpublishReportType": "Unpublish this report from moible application.",
"confirmTransition": "Are you want to change status to {{stepName}} ?"
"confirmTransition": "Are you want to change status to {{stepName}} ?",
"confirmConvertToTest": "Would like to change this report to test report?"
}
},
"title": {
Expand Down Expand Up @@ -221,5 +222,14 @@
"qr": {
"login": "Login QR Code",
"reportTypeFormDefinition": "Form Definition QR Code"
},
"status": {
"case": "case",
"suspectedOutbreak": "suspected outbreak",
"outbreak": "outbreak",
"actions": {
"promoteToCase": "Promote to case",
"convertToTest": "Convert to test report"
}
}
}
22 changes: 17 additions & 5 deletions i18n/translations.la.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"caseDefinitions": "ຄໍານິຍາມກໍລະນີ",
"stateDefinitions": "ຕັ້ງ​ສະ​ຖາ​ນະ​ພາບ​",
"notificationTemplates": "ແມ່ແບບການແຈ້ງເຕືອນ",
"notifications": "ແຈ້ງການ",
"reporterNotifications": "ແຈ້ງ​ການ​ນັກ​ຂ່າວ​",
"notifications": "ແຈ້ງເຕືອນ",
"reporterNotifications": "ແຈ້ງ​ຄືນໃຫ້ອາສາ",
"profile": "ໂປຣໄຟລ໌",
"create": "ສ້າງ",
"update": "ອັບເດດ",
Expand All @@ -25,8 +25,8 @@
"contributions": "ລາຍ​ງານ​ປະ​ຫວັດ​ສາດ​",
"observationDefinitions": "ຄໍາ​ນິ​ຍາມ​ການ​ສັງ​ເກດ​ການ",
"observationMonitoringDefinitions": "ຄໍານິຍາມການຕິດຕາມການສັງເກດ",
"inactiveReporter": "ນັກຂ່າວທີ່ບໍ່ເຄື່ອນໄຫວ",
"reporterPerformance": "ຜົນງານຂອງນັກຂ່າວ"
"inactiveReporter": "ອາສາທີ່ບໍ່ເຄື່ອນໄຫວ",
"reporterPerformance": "ຜົນງານຂອງອາສາ"
},
"filter": {
"searchButton": "ປຸ່ມຊອກຫາ",
Expand Down Expand Up @@ -191,7 +191,9 @@
"confirmDelete": "ຢືນຢັນການລຶບ ?",
"confirmPublishReportType": "ທ່ານແນ່ໃຈບໍ່ວ່າຢືນຢັນການເຜີຍແຜ່ປະເພດລາຍງານ ?",
"confirmUnpublishReportType": "ທ່ານແນ່ໃຈບໍ່ວ່າຢືນຢັນປະເພດລາຍງານທີ່ບໍ່ໄດ້ເຜີຍແຜ່ ?",
"confirmTransition": "ທ່ານຕ້ອງການປ່ຽນສະຖານະເປັນ {{stepName}} ?"
"confirmTransition": "ທ່ານຕ້ອງການປ່ຽນສະຖານະເປັນ {{stepName}} ?",
"confirmConvertToTest": "ທ່ານຕ້ອງການປ່ຽນສະຖານະເປັນທົດສອບ ?",
"confirmToPromoteToCase": "ທ່ານຕ້ອງການປ່ຽນສະຖານະເປັນກໍລະນີ ?"
}
},
"title": {
Expand Down Expand Up @@ -230,5 +232,15 @@
"qr": {
"login": "ເຂົ້າສູ່ລະບົບດ້ວຍລະຫັດ qr",
"reportTypeFormDefinition": "Form Definition QR Code"
},
"status": {
"test": "ທົດສອບ",
"case": "ກໍລະນີ",
"suspectedOutbreak": "suspected outbreak",
"outbreak": "outbreak",
"actions": {
"promoteToCase": "ປ່ຽນເປັນກໍລະນີ",
"convertToTest": "ປ່ຽນເປັນທົດສອບ"
}
}
}

0 comments on commit a25f1a9

Please sign in to comment.