From eac769fc72dd5f559cccf48913effa95b8976379 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Tue, 19 Dec 2023 11:35:08 -0800 Subject: [PATCH 01/31] add translationVerified checkbox to identificationTab --- src/components/Tabs/IdentificationTab.jsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index c2c5fe7f..9bded723 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -10,6 +10,8 @@ import { import CircularProgress from "@material-ui/core/CircularProgress"; import { useParams } from "react-router-dom"; import { OpenInNew, Update } from "@material-ui/icons"; +import FormControlLabel from "@material-ui/core/FormControlLabel"; +import Checkbox from "@material-ui/core/Checkbox"; import { En, Fr, I18n } from "../I18n"; import { progressCodes } from "../../isoCodeLists"; import { eovs, eovCategories } from "../../eovs.json"; @@ -250,6 +252,17 @@ const IdentificationTab = ({ onChange={handleUpdateRecord("title")} disabled={disabled} /> + + } + label="I have verified this translation" + /> From d25815e1507dcf475af10e01b303851e57fa8616 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Wed, 20 Dec 2023 10:05:25 -0800 Subject: [PATCH 02/31] fix translationVerified checkbox --- src/components/Tabs/IdentificationTab.jsx | 62 +++++++++++------------ 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index 9bded723..eb05019c 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -255,13 +255,21 @@ const IdentificationTab = ({ { + const { checked } = e.target; + updateRecord("translationVerified")(checked); + }} color="primary" /> } - label="I have verified this translation" + label={ + + I have verified this translation + J'ai vérifié cette traduction + + } /> @@ -719,13 +727,12 @@ const IdentificationTab = ({ -

- Please save the form before generating a draft DOI. -

+

Please save the form before generating a draft DOI.

- Veuillez enregistrer le formulaire avant de générer un brouillon de DOI. + Veuillez enregistrer le formulaire avant de générer un + brouillon de DOI.

@@ -751,15 +758,12 @@ const IdentificationTab = ({ )} {showUpdateDoi && ( - )} - {showDeleteDoi && ( - - )} + + ) : ( + "Delete Draft DOI" + )} + + + )} {doiErrorFlag && ( - + )} From 3ed8382d43ecfbd31d9d872ab34660f529068901 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Wed, 20 Dec 2023 10:20:10 -0800 Subject: [PATCH 03/31] add translationVerified checkbox for abstract --- src/components/Tabs/IdentificationTab.jsx | 25 ++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index eb05019c..72e65790 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -255,11 +255,11 @@ const IdentificationTab = ({ { const { checked } = e.target; - updateRecord("translationVerified")(checked); + updateRecord("titleTranslationVerified")(checked); }} color="primary" /> @@ -416,6 +416,25 @@ const IdentificationTab = ({ disabled={disabled} multiline /> + { + const { checked } = e.target; + updateRecord("abstractTranslationVerified")(checked); + }} + color="primary" + /> + } + label={ + + I have verified this translation + J'ai vérifié cette traduction + + } + /> From 1985a1fef4f50217469b7b135734576335b40831 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Wed, 20 Dec 2023 10:22:36 -0800 Subject: [PATCH 04/31] add translationVerified checkbox for limitations --- src/components/Tabs/IdentificationTab.jsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index 72e65790..e8e9b674 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -986,6 +986,25 @@ const IdentificationTab = ({ multiline disabled={disabled} /> + { + const { checked } = e.target; + updateRecord("limitationsTranslationVerified")(checked); + }} + color="primary" + /> + } + label={ + + I have verified this translation + J'ai vérifié cette traduction + + } + /> ); From 48feafccc59cf0016f3e48a66c8b16925d429edb Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Wed, 20 Dec 2023 10:42:27 -0800 Subject: [PATCH 05/31] add translationVerified checkbox for platformDescription --- src/components/FormComponents/Platform.jsx | 23 +++++++++++++++++++++- src/components/Tabs/PlatformTab.jsx | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/components/FormComponents/Platform.jsx b/src/components/FormComponents/Platform.jsx index 0bfce772..7051b6da 100644 --- a/src/components/FormComponents/Platform.jsx +++ b/src/components/FormComponents/Platform.jsx @@ -3,6 +3,8 @@ import React from "react"; import { TextField, Grid, Tooltip } from "@material-ui/core"; import { useParams } from "react-router-dom"; import { OpenInNew } from "@material-ui/icons"; +import FormControlLabel from "@material-ui/core/FormControlLabel"; +import Checkbox from "@material-ui/core/Checkbox"; import BilingualTextInput from "./BilingualTextInput"; import { QuestionText, SupplementalText, paperClass } from "./QuestionStyles"; @@ -12,7 +14,7 @@ import { validateField } from "../../utils/validate"; import SelectInput from "./SelectInput"; import platforms from "../../platforms.json"; -const Platform = ({ record, handleUpdateRecord, disabled }) => { +const Platform = ({ record, handleUpdateRecord, disabled, updateRecord }) => { const { language = "en" } = useParams(); const platformsSorted = Object.values(platforms).sort((a, b) => @@ -140,6 +142,25 @@ const Platform = ({ record, handleUpdateRecord, disabled }) => { multiline disabled={disabled} /> + { + const { checked } = e.target; + updateRecord("platformDescriptionTranslationVerified")(checked); + }} + color="primary" + /> + } + label={ + + I have verified this translation + J'ai vérifié cette traduction + + } + /> ); diff --git a/src/components/Tabs/PlatformTab.jsx b/src/components/Tabs/PlatformTab.jsx index 82f8c1bc..6612720d 100644 --- a/src/components/Tabs/PlatformTab.jsx +++ b/src/components/Tabs/PlatformTab.jsx @@ -87,6 +87,7 @@ const PlatformTab = ({ From b2853a5144fff7d519aa80a8606d71b52e8b6a8b Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Wed, 20 Dec 2023 12:30:30 -0800 Subject: [PATCH 06/31] update component to receive props for dynamic checkbox --- .../FormComponents/BilingualTextInput.jsx | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/components/FormComponents/BilingualTextInput.jsx b/src/components/FormComponents/BilingualTextInput.jsx index 29cdc423..efd4a45e 100644 --- a/src/components/FormComponents/BilingualTextInput.jsx +++ b/src/components/FormComponents/BilingualTextInput.jsx @@ -6,6 +6,8 @@ import { CircularProgress, Tooltip, } from "@material-ui/core"; +import FormControlLabel from "@material-ui/core/FormControlLabel"; +import Checkbox from "@material-ui/core/Checkbox"; import TranslateIcon from "@material-ui/icons/Translate"; import ArrowDownwardIcon from "@material-ui/icons/ArrowDownward"; import { useParams } from "react-router-dom"; @@ -23,6 +25,8 @@ const BilingualTextInput = ({ disabled, error, translationButonDisabled = false, + translateChecked, + translateOnChange, }) => { const { translate } = useContext(UserContext); const [awaitingTranslation, setAwaitingTranslation] = useState(false); @@ -109,6 +113,25 @@ const BilingualTextInput = ({ Traduire + {translateOnChange && ( + + } + label={ + + I have verified this translation + J'ai vérifié cette traduction + + } + /> + )} + {textTooBig && ( From 14b9dfd06db1bab413be9077c41217ad67e1b17d Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Wed, 20 Dec 2023 12:31:08 -0800 Subject: [PATCH 07/31] move verifyTranslate into bilingualTextInput --- src/components/FormComponents/Platform.jsx | 30 +++++++--------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/components/FormComponents/Platform.jsx b/src/components/FormComponents/Platform.jsx index 7051b6da..152898f2 100644 --- a/src/components/FormComponents/Platform.jsx +++ b/src/components/FormComponents/Platform.jsx @@ -3,8 +3,6 @@ import React from "react"; import { TextField, Grid, Tooltip } from "@material-ui/core"; import { useParams } from "react-router-dom"; import { OpenInNew } from "@material-ui/icons"; -import FormControlLabel from "@material-ui/core/FormControlLabel"; -import Checkbox from "@material-ui/core/Checkbox"; import BilingualTextInput from "./BilingualTextInput"; import { QuestionText, SupplementalText, paperClass } from "./QuestionStyles"; @@ -141,25 +139,15 @@ const Platform = ({ record, handleUpdateRecord, disabled, updateRecord }) => { onChange={handleUpdateRecord("platformDescription")} multiline disabled={disabled} - /> - { - const { checked } = e.target; - updateRecord("platformDescriptionTranslationVerified")(checked); - }} - color="primary" - /> - } - label={ - - I have verified this translation - J'ai vérifié cette traduction - - } + translateChecked={ + record.platformDescriptionTranslationVerified || false + } + translateOnChange={(e) => { + const { checked } = e.target; + updateRecord("platformDescriptionTranslationVerified")( + checked + ); + }} /> From da95ab6f9c69969bc6abe7fde1dd4d876aff2c5f Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Wed, 20 Dec 2023 12:34:45 -0800 Subject: [PATCH 08/31] move verifyTranslate into bilingualTextInput --- src/components/Tabs/IdentificationTab.jsx | 86 +++++++---------------- 1 file changed, 27 insertions(+), 59 deletions(-) diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index e8e9b674..35f0a2eb 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -10,8 +10,6 @@ import { import CircularProgress from "@material-ui/core/CircularProgress"; import { useParams } from "react-router-dom"; import { OpenInNew, Update } from "@material-ui/icons"; -import FormControlLabel from "@material-ui/core/FormControlLabel"; -import Checkbox from "@material-ui/core/Checkbox"; import { En, Fr, I18n } from "../I18n"; import { progressCodes } from "../../isoCodeLists"; import { eovs, eovCategories } from "../../eovs.json"; @@ -251,25 +249,15 @@ const IdentificationTab = ({ value={record.title} onChange={handleUpdateRecord("title")} disabled={disabled} - /> - { - const { checked } = e.target; - updateRecord("titleTranslationVerified")(checked); - }} - color="primary" - /> - } - label={ - - I have verified this translation - J'ai vérifié cette traduction - - } + translateChecked={ + record.titleTranslationVerified || false + } + translateOnChange={(e) => { + const { checked } = e.target; + updateRecord("titleTranslationVerified")( + checked + ); + }} /> @@ -415,25 +403,15 @@ const IdentificationTab = ({ onChange={handleUpdateRecord("abstract")} disabled={disabled} multiline - /> - { - const { checked } = e.target; - updateRecord("abstractTranslationVerified")(checked); - }} - color="primary" - /> - } - label={ - - I have verified this translation - J'ai vérifié cette traduction - - } + translateChecked={ + record.abstractTranslationVerified || false + } + translateOnChange={(e) => { + const { checked } = e.target; + updateRecord("abstractTranslationVerified")( + checked + ); + }} /> @@ -985,25 +963,15 @@ const IdentificationTab = ({ onChange={handleUpdateRecord("limitations")} multiline disabled={disabled} - /> - { - const { checked } = e.target; - updateRecord("limitationsTranslationVerified")(checked); - }} - color="primary" - /> - } - label={ - - I have verified this translation - J'ai vérifié cette traduction - - } + translateChecked={ + record.limitationsTranslationVerified || false + } + translateOnChange={(e) => { + const { checked } = e.target; + updateRecord("limitationsTranslationVerified")( + checked + ); + }} /> From e86d05b53878065c574f73f0d428e86f3157ed4a Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Wed, 20 Dec 2023 12:53:11 -0800 Subject: [PATCH 09/31] update translationVerified variable names --- src/components/FormComponents/Platform.jsx | 4 ++-- src/components/Tabs/IdentificationTab.jsx | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/FormComponents/Platform.jsx b/src/components/FormComponents/Platform.jsx index 152898f2..98904f56 100644 --- a/src/components/FormComponents/Platform.jsx +++ b/src/components/FormComponents/Platform.jsx @@ -140,11 +140,11 @@ const Platform = ({ record, handleUpdateRecord, disabled, updateRecord }) => { multiline disabled={disabled} translateChecked={ - record.platformDescriptionTranslationVerified || false + record.translationVerifiedPlatformDescription || false } translateOnChange={(e) => { const { checked } = e.target; - updateRecord("platformDescriptionTranslationVerified")( + updateRecord("translationVerifiedPlatformDescription")( checked ); }} diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index 35f0a2eb..560b45a3 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -206,6 +206,7 @@ const IdentificationTab = ({ } } + console.log(record) return (
@@ -250,11 +251,11 @@ const IdentificationTab = ({ onChange={handleUpdateRecord("title")} disabled={disabled} translateChecked={ - record.titleTranslationVerified || false + record.translationVerifiedTitle || false } translateOnChange={(e) => { const { checked } = e.target; - updateRecord("titleTranslationVerified")( + updateRecord("translationVerifiedTitle")( checked ); }} @@ -404,11 +405,11 @@ const IdentificationTab = ({ disabled={disabled} multiline translateChecked={ - record.abstractTranslationVerified || false + record.translationVerifiedAbstract || false } translateOnChange={(e) => { const { checked } = e.target; - updateRecord("abstractTranslationVerified")( + updateRecord("translationVerifiedAbstract")( checked ); }} @@ -964,11 +965,11 @@ const IdentificationTab = ({ multiline disabled={disabled} translateChecked={ - record.limitationsTranslationVerified || false + record.translationVerifiedLimitations || false } translateOnChange={(e) => { const { checked } = e.target; - updateRecord("limitationsTranslationVerified")( + updateRecord("translationVerifiedLimitations")( checked ); }} From b5b1b4063214e44c336aed0678614d6675016e2e Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Tue, 9 Jan 2024 16:28:42 -0800 Subject: [PATCH 10/31] add new prop and invoke prop function to pass a message --- src/components/FormComponents/BilingualTextInput.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/FormComponents/BilingualTextInput.jsx b/src/components/FormComponents/BilingualTextInput.jsx index efd4a45e..79a543f9 100644 --- a/src/components/FormComponents/BilingualTextInput.jsx +++ b/src/components/FormComponents/BilingualTextInput.jsx @@ -27,6 +27,7 @@ const BilingualTextInput = ({ translationButonDisabled = false, translateChecked, translateOnChange, + onTranslateComplete, }) => { const { translate } = useContext(UserContext); const [awaitingTranslation, setAwaitingTranslation] = useState(false); @@ -104,6 +105,7 @@ const BilingualTextInput = ({ value: translation, }, }); + onTranslateComplete(`Auto-translated using AWS`); } ); }} From 199ad50d2c8ace7d23c5646029ddde91a997fa07 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Tue, 9 Jan 2024 16:36:14 -0800 Subject: [PATCH 11/31] define translateMethod handler and pass to BilingualTextInput --- src/components/Tabs/IdentificationTab.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index 560b45a3..40ec81fe 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -78,6 +78,10 @@ const IdentificationTab = ({ ) ); + const handleTranslationComplete = (message) => { + updateRecord("translationMethod")(message); + }; + async function handleGenerateDOI() { setLoadingDoi(true); @@ -249,6 +253,7 @@ const IdentificationTab = ({ Date: Tue, 9 Jan 2024 16:47:29 -0800 Subject: [PATCH 12/31] pass handler to Platform.jsx --- src/components/Tabs/PlatformTab.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/Tabs/PlatformTab.jsx b/src/components/Tabs/PlatformTab.jsx index 6612720d..73fb57d5 100644 --- a/src/components/Tabs/PlatformTab.jsx +++ b/src/components/Tabs/PlatformTab.jsx @@ -11,6 +11,7 @@ const PlatformTab = ({ disabled, record, handleUpdateRecord, + handleTranslationComplete, updateRecord, }) => { const noPlatform = record.noPlatform && record.noPlatform !== "false"; @@ -87,6 +88,7 @@ const PlatformTab = ({ From 25b77f83835ce766e0cac41542865add0432ca05 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Tue, 9 Jan 2024 16:48:24 -0800 Subject: [PATCH 13/31] pass handler to BilingualTextInput --- src/components/FormComponents/Platform.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/FormComponents/Platform.jsx b/src/components/FormComponents/Platform.jsx index 98904f56..2fddb082 100644 --- a/src/components/FormComponents/Platform.jsx +++ b/src/components/FormComponents/Platform.jsx @@ -12,7 +12,7 @@ import { validateField } from "../../utils/validate"; import SelectInput from "./SelectInput"; import platforms from "../../platforms.json"; -const Platform = ({ record, handleUpdateRecord, disabled, updateRecord }) => { +const Platform = ({ record, handleUpdateRecord, handleTranslationComplete, disabled, updateRecord }) => { const { language = "en" } = useParams(); const platformsSorted = Object.values(platforms).sort((a, b) => @@ -137,6 +137,7 @@ const Platform = ({ record, handleUpdateRecord, disabled, updateRecord }) => { Date: Tue, 9 Jan 2024 17:25:33 -0800 Subject: [PATCH 14/31] dynamically generate handler based on field name --- src/components/Tabs/IdentificationTab.jsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index 40ec81fe..7f6974d7 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -78,8 +78,9 @@ const IdentificationTab = ({ ) ); - const handleTranslationComplete = (message) => { - updateRecord("translationMethod")(message); + const handleTranslationComplete = (fieldName) => (message) => { + const translationMethodField = `${fieldName}TranslationMethod`; + updateRecord(translationMethodField)(message); }; async function handleGenerateDOI() { @@ -253,7 +254,7 @@ const IdentificationTab = ({ Date: Tue, 9 Jan 2024 17:26:06 -0800 Subject: [PATCH 15/31] pass field name to handler --- src/components/FormComponents/Platform.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/FormComponents/Platform.jsx b/src/components/FormComponents/Platform.jsx index 2fddb082..dfb51802 100644 --- a/src/components/FormComponents/Platform.jsx +++ b/src/components/FormComponents/Platform.jsx @@ -137,7 +137,7 @@ const Platform = ({ record, handleUpdateRecord, handleTranslationComplete, disab Date: Wed, 10 Jan 2024 14:11:16 -0800 Subject: [PATCH 16/31] fix scoping issue with handleTranslationComplete --- src/components/Pages/MetadataForm.jsx | 6 ++++++ src/components/Tabs/IdentificationTab.jsx | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/Pages/MetadataForm.jsx b/src/components/Pages/MetadataForm.jsx index 98d38627..0a35e0dc 100644 --- a/src/components/Pages/MetadataForm.jsx +++ b/src/components/Pages/MetadataForm.jsx @@ -227,6 +227,11 @@ class MetadataForm extends FormClassTemplate { })); }; + handleTranslationComplete = (fieldName) => (message) => { + const translationMethodField = `${fieldName}TranslationMethod`; + this.updateRecord(translationMethodField)(message); + }; + saveUpdateContact(contact) { const { contactID } = contact; const { match } = this.props; @@ -374,6 +379,7 @@ class MetadataForm extends FormClassTemplate { record, handleUpdateRecord: this.handleUpdateRecord, updateRecord: this.updateRecord, + handleTranslationComplete: this.handleTranslationComplete, }; const percentValidInt = Math.round(percentValid(record) * 100); return loading ? ( diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index 7f6974d7..ce44af5b 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -39,6 +39,7 @@ const IdentificationTab = ({ record, handleUpdateRecord, updateRecord, + handleTranslationComplete, projects, }) => { const { createDraftDoi, updateDraftDoi, deleteDraftDoi } = useContext(UserContext); @@ -78,11 +79,6 @@ const IdentificationTab = ({ ) ); - const handleTranslationComplete = (fieldName) => (message) => { - const translationMethodField = `${fieldName}TranslationMethod`; - updateRecord(translationMethodField)(message); - }; - async function handleGenerateDOI() { setLoadingDoi(true); From c9128162f624c31b5a699fdf239d878f03f58c77 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Thu, 11 Jan 2024 13:36:00 -0800 Subject: [PATCH 17/31] remove console log --- src/components/Tabs/IdentificationTab.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index ce44af5b..30c430a5 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -207,7 +207,6 @@ const IdentificationTab = ({ } } - console.log(record) return (
From 5b72ce2e54fce484e4bcbd7b59b4409f772f1d6d Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Thu, 11 Jan 2024 13:52:39 -0800 Subject: [PATCH 18/31] define verify_translation function --- firebase_to_xml/firebase_to_xml/record_json_to_yaml.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/firebase_to_xml/firebase_to_xml/record_json_to_yaml.py b/firebase_to_xml/firebase_to_xml/record_json_to_yaml.py index 9cd45382..f98e1e1e 100644 --- a/firebase_to_xml/firebase_to_xml/record_json_to_yaml.py +++ b/firebase_to_xml/firebase_to_xml/record_json_to_yaml.py @@ -30,6 +30,10 @@ def eovs_to_fr(eovs_en): """ Translate a list of EOVs in english to a list in french""" return [eov_translations.get(eov,"") for eov in eovs_en if eov] +def verify_translation(verified, message): + if not verified: + return message + return "" def strip_keywords(keywords): """Strips whitespace from each keyword in either language""" From feeb56eb32d8f39c5eda3e509763c92f65217fb8 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Thu, 11 Jan 2024 13:54:19 -0800 Subject: [PATCH 19/31] add translation method field to record_yaml --- firebase_to_xml/firebase_to_xml/record_json_to_yaml.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/firebase_to_xml/firebase_to_xml/record_json_to_yaml.py b/firebase_to_xml/firebase_to_xml/record_json_to_yaml.py index f98e1e1e..8e2f7909 100644 --- a/firebase_to_xml/firebase_to_xml/record_json_to_yaml.py +++ b/firebase_to_xml/firebase_to_xml/record_json_to_yaml.py @@ -77,6 +77,7 @@ def record_json_to_yaml(record): + "https://cioos-siooc.github.io/metadata-entry-form", "use_constraints": { "limitations": record.get("limitations", "None"), + "limitationsTranslationMethod": verify_translation(record.get("translationVerifiedLimitations"), record.get("limitationsTranslationMethod")), "licence": licenses.get( record.get( "license", @@ -107,8 +108,10 @@ def record_json_to_yaml(record): }, "identification": { "title": record.get("title"), + "titleTranslationMethod": verify_translation(record.get("translationVerifiedTitle"), record.get("titleTranslationMethod")), "identifier": record.get("datasetIdentifier"), "abstract": record.get("abstract"), + "abstractTranslationMethod": verify_translation(record.get("translationVerifiedAbstract"), record.get("abstractTranslationMethod")), "dates": { "creation": date_from_datetime_str(record.get("dateStart")), "publication": date_from_datetime_str(record.get("datePublished")), @@ -162,6 +165,7 @@ def record_json_to_yaml(record): record_yaml["platform"] = { "id": record.get("platformID"), "description": record.get("platformDescription"), + "platformDescriptionTranslationMethod": verify_translation(record.get("translationVerifiedPlatformDescription"), record.get("platformDescriptionTranslationMethod")), "type": record.get("platform"), } From 3fe64b26b3687e5a57ae1444aeb265988507c8b5 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Thu, 11 Jan 2024 16:04:11 -0800 Subject: [PATCH 20/31] remove unnecessary checkbox name --- src/components/FormComponents/BilingualTextInput.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/FormComponents/BilingualTextInput.jsx b/src/components/FormComponents/BilingualTextInput.jsx index 79a543f9..4a51f8c6 100644 --- a/src/components/FormComponents/BilingualTextInput.jsx +++ b/src/components/FormComponents/BilingualTextInput.jsx @@ -119,7 +119,6 @@ const BilingualTextInput = ({ Date: Fri, 12 Jan 2024 14:51:48 -0800 Subject: [PATCH 21/31] update hardcoded translate message, pass message directly to handleTranslationComplete --- src/components/FormComponents/BilingualTextInput.jsx | 2 +- src/components/FormComponents/Platform.jsx | 2 +- src/components/Pages/MetadataForm.jsx | 4 ++-- src/components/Tabs/IdentificationTab.jsx | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/FormComponents/BilingualTextInput.jsx b/src/components/FormComponents/BilingualTextInput.jsx index 4a51f8c6..35fde56d 100644 --- a/src/components/FormComponents/BilingualTextInput.jsx +++ b/src/components/FormComponents/BilingualTextInput.jsx @@ -105,7 +105,7 @@ const BilingualTextInput = ({ value: translation, }, }); - onTranslateComplete(`Auto-translated using AWS`); + onTranslateComplete(); } ); }} diff --git a/src/components/FormComponents/Platform.jsx b/src/components/FormComponents/Platform.jsx index dfb51802..ccd9ca99 100644 --- a/src/components/FormComponents/Platform.jsx +++ b/src/components/FormComponents/Platform.jsx @@ -137,7 +137,7 @@ const Platform = ({ record, handleUpdateRecord, handleTranslationComplete, disab (message) => { + handleTranslationComplete = (fieldName, translateMessage) => () => { const translationMethodField = `${fieldName}TranslationMethod`; - this.updateRecord(translationMethodField)(message); + this.updateRecord(translationMethodField)(translateMessage); }; saveUpdateContact(contact) { diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index 014fdb32..d19276d1 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -254,7 +254,7 @@ const IdentificationTab = ({ Date: Mon, 29 Jan 2024 13:32:21 -0800 Subject: [PATCH 22/31] add translation verification to resources --- src/components/FormComponents/Resources.jsx | 37 +++++++++++++++++++++ src/components/Tabs/ResourcesTab.jsx | 3 ++ 2 files changed, 40 insertions(+) diff --git a/src/components/FormComponents/Resources.jsx b/src/components/FormComponents/Resources.jsx index 3030b31e..dd804d54 100644 --- a/src/components/FormComponents/Resources.jsx +++ b/src/components/FormComponents/Resources.jsx @@ -35,6 +35,37 @@ const Resources = ({ updateResources, resources, disabled }) => { resources.splice(newIndex, 0, element); updateResources(resources); } + + const handleResourceTranslationComplete = (resourceIndex, fieldName, translateMessage) => () => { + const updatedResources = resources.map((resource, index) => { + if (index === resourceIndex) { + return { + ...resource, + [`${fieldName}TranslationMethod`]: translateMessage, + }; + } + return resource; + }); + + updateResources(updatedResources); + }; + + const handleTranslateVerifyChange = (resourceIndex, field) => { + return (e) => { + const { checked } = e.target; + const updatedResources = resources.map((resource, index) => { + if (index === resourceIndex) { + return { + ...resource, + [`${field}TranslationVerified`]: checked, + }; + } + return resource; + }); + updateResources(updatedResources); + }; + } + const nameLabel = ; const descriptionLabel = ; @@ -64,8 +95,11 @@ const Resources = ({ updateResources, resources, disabled }) => { label={nameLabel} value={dist.name} onChange={handleResourceChange("name")} + onTranslateComplete={handleResourceTranslationComplete(i, "name", "Resource name text translated using the Amazon translate service / Texte du nom de la ressource traduit à l'aide du service de traduction Amazon")} fullWidth disabled={disabled} + translateChecked={dist.nameTranslationVerified || false} + translateOnChange={handleTranslateVerifyChange(i, "name")} /> @@ -121,7 +155,10 @@ const Resources = ({ updateResources, resources, disabled }) => { label={descriptionLabel} value={dist.description} onChange={handleResourceChange("description")} + onTranslateComplete={handleResourceTranslationComplete(i, "description", "Resource description text translated using the Amazon translate service / Texte de description de la ressource traduit à l'aide du service de traduction Amazon")} disabled={disabled} + translateChecked={dist.descriptionTranslationVerified || false} + translateOnChange={handleTranslateVerifyChange(i, "description")} /> diff --git a/src/components/Tabs/ResourcesTab.jsx b/src/components/Tabs/ResourcesTab.jsx index 8e628cbb..57cfbc83 100644 --- a/src/components/Tabs/ResourcesTab.jsx +++ b/src/components/Tabs/ResourcesTab.jsx @@ -14,6 +14,9 @@ import { validateField } from "../../utils/validate"; const ResourcesTab = ({ disabled, record, updateRecord }) => { const updateResources = updateRecord("distribution"); + + console.log(record); + return (
From bd5155c804208550885dcd1dcf632405c04122df Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Mon, 29 Jan 2024 15:18:16 -0800 Subject: [PATCH 23/31] encapsulate verify translate checkbox logic into a function --- src/components/FormComponents/Platform.jsx | 13 ++------ src/components/FormComponents/Resources.jsx | 6 ++-- src/components/Pages/MetadataForm.jsx | 8 +++++ src/components/Tabs/IdentificationTab.jsx | 34 +++++---------------- src/components/Tabs/PlatformTab.jsx | 3 +- src/components/Tabs/ResourcesTab.jsx | 4 +-- 6 files changed, 24 insertions(+), 44 deletions(-) diff --git a/src/components/FormComponents/Platform.jsx b/src/components/FormComponents/Platform.jsx index ccd9ca99..7e444059 100644 --- a/src/components/FormComponents/Platform.jsx +++ b/src/components/FormComponents/Platform.jsx @@ -12,7 +12,7 @@ import { validateField } from "../../utils/validate"; import SelectInput from "./SelectInput"; import platforms from "../../platforms.json"; -const Platform = ({ record, handleUpdateRecord, handleTranslationComplete, disabled, updateRecord }) => { +const Platform = ({ record, handleUpdateRecord, handleTranslationComplete, handleTranslateVerifyChange, disabled }) => { const { language = "en" } = useParams(); const platformsSorted = Object.values(platforms).sort((a, b) => @@ -140,15 +140,8 @@ const Platform = ({ record, handleUpdateRecord, handleTranslationComplete, disab onTranslateComplete={handleTranslationComplete("platformDescription", "Platform Description text translated using the Amazon translate service / Texte de description de la plateforme traduit à l'aide du service de traduction Amazon")} multiline disabled={disabled} - translateChecked={ - record.translationVerifiedPlatformDescription || false - } - translateOnChange={(e) => { - const { checked } = e.target; - updateRecord("translationVerifiedPlatformDescription")( - checked - ); - }} + translateChecked={record.translationVerifiedPlatformDescription || false} + translateOnChange={handleTranslateVerifyChange("translationVerifiedPlatformDescription")} />
diff --git a/src/components/FormComponents/Resources.jsx b/src/components/FormComponents/Resources.jsx index dd804d54..604423f3 100644 --- a/src/components/FormComponents/Resources.jsx +++ b/src/components/FormComponents/Resources.jsx @@ -50,7 +50,7 @@ const Resources = ({ updateResources, resources, disabled }) => { updateResources(updatedResources); }; - const handleTranslateVerifyChange = (resourceIndex, field) => { + const handleResourceTranslateVerifyChange = (resourceIndex, field) => { return (e) => { const { checked } = e.target; const updatedResources = resources.map((resource, index) => { @@ -99,7 +99,7 @@ const Resources = ({ updateResources, resources, disabled }) => { fullWidth disabled={disabled} translateChecked={dist.nameTranslationVerified || false} - translateOnChange={handleTranslateVerifyChange(i, "name")} + translateOnChange={handleResourceTranslateVerifyChange(i, "name")} />
@@ -158,7 +158,7 @@ const Resources = ({ updateResources, resources, disabled }) => { onTranslateComplete={handleResourceTranslationComplete(i, "description", "Resource description text translated using the Amazon translate service / Texte de description de la ressource traduit à l'aide du service de traduction Amazon")} disabled={disabled} translateChecked={dist.descriptionTranslationVerified || false} - translateOnChange={handleTranslateVerifyChange(i, "description")} + translateOnChange={handleResourceTranslateVerifyChange(i, "description")} /> diff --git a/src/components/Pages/MetadataForm.jsx b/src/components/Pages/MetadataForm.jsx index 90d94aa0..a0b92be8 100644 --- a/src/components/Pages/MetadataForm.jsx +++ b/src/components/Pages/MetadataForm.jsx @@ -236,6 +236,13 @@ class MetadataForm extends FormClassTemplate { this.updateRecord(translationMethodField)(translateMessage); }; + handleTranslateVerifyChange = (fieldName) => { + return (e) => { + const { checked } = e.target; + this.updateRecord(fieldName)(checked); + }; + } + saveUpdateContact(contact) { const { contactID } = contact; const { match } = this.props; @@ -384,6 +391,7 @@ class MetadataForm extends FormClassTemplate { handleUpdateRecord: this.handleUpdateRecord, updateRecord: this.updateRecord, handleTranslationComplete: this.handleTranslationComplete, + handleTranslateVerifyChange: this.handleTranslateVerifyChange, }; const percentValidInt = Math.round(percentValid(record) * 100); return loading ? ( diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index e5f5f99f..c707509a 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -41,6 +41,7 @@ const IdentificationTab = ({ handleUpdateRecord, updateRecord, handleTranslationComplete, + handleTranslateVerifyChange, projects, }) => { const { createDraftDoi, updateDraftDoi, deleteDraftDoi, getDoiStatus } = useContext(UserContext); @@ -284,15 +285,8 @@ const IdentificationTab = ({ onChange={handleUpdateRecord("title")} onTranslateComplete={handleTranslationComplete("title", "Title text translated using the Amazon translate service / Texte du titre traduit à l’aide du service de traduction Amazon")} disabled={disabled} - translateChecked={ - record.translationVerifiedTitle || false - } - translateOnChange={(e) => { - const { checked } = e.target; - updateRecord("translationVerifiedTitle")( - checked - ); - }} + translateChecked={record.translationVerifiedTitle || false} + translateOnChange={handleTranslateVerifyChange("translationVerifiedTitle")} />
@@ -439,15 +433,8 @@ const IdentificationTab = ({ onTranslateComplete={handleTranslationComplete("abstract", "Abstract text translated using the Amazon translate service / Texte abstrait traduit à l'aide du service de traduction Amazon")} disabled={disabled} multiline - translateChecked={ - record.translationVerifiedAbstract || false - } - translateOnChange={(e) => { - const { checked } = e.target; - updateRecord("translationVerifiedAbstract")( - checked - ); - }} + translateChecked={record.translationVerifiedAbstract || false} + translateOnChange={handleTranslateVerifyChange("translationVerifiedAbstract")} /> @@ -1010,15 +997,8 @@ const IdentificationTab = ({ onTranslateComplete={handleTranslationComplete("limitations", "Limitations text translated using the Amazon translate service / Texte des limitations traduit à l'aide du service de traduction Amazon")} multiline disabled={disabled} - translateChecked={ - record.translationVerifiedLimitations || false - } - translateOnChange={(e) => { - const { checked } = e.target; - updateRecord("translationVerifiedLimitations")( - checked - ); - }} + translateChecked={record.translationVerifiedLimitations || false} + translateOnChange={handleTranslateVerifyChange("translationVerifiedLimitations")} />
diff --git a/src/components/Tabs/PlatformTab.jsx b/src/components/Tabs/PlatformTab.jsx index 73fb57d5..374ba52a 100644 --- a/src/components/Tabs/PlatformTab.jsx +++ b/src/components/Tabs/PlatformTab.jsx @@ -12,6 +12,7 @@ const PlatformTab = ({ record, handleUpdateRecord, handleTranslationComplete, + handleTranslateVerifyChange, updateRecord, }) => { const noPlatform = record.noPlatform && record.noPlatform !== "false"; @@ -89,7 +90,7 @@ const PlatformTab = ({ record={record} handleUpdateRecord={handleUpdateRecord} handleTranslationComplete={handleTranslationComplete} - updateRecord={updateRecord} + handleTranslateVerifyChange={handleTranslateVerifyChange} disabled={disabled} /> diff --git a/src/components/Tabs/ResourcesTab.jsx b/src/components/Tabs/ResourcesTab.jsx index 57cfbc83..d1d2d55e 100644 --- a/src/components/Tabs/ResourcesTab.jsx +++ b/src/components/Tabs/ResourcesTab.jsx @@ -14,9 +14,7 @@ import { validateField } from "../../utils/validate"; const ResourcesTab = ({ disabled, record, updateRecord }) => { const updateResources = updateRecord("distribution"); - - console.log(record); - + return (
From 5c4b61a50cf79d4297d577c68d3f103c810eb87e Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Mon, 29 Jan 2024 15:56:25 -0800 Subject: [PATCH 24/31] replace dist with resourceItem --- src/components/FormComponents/Resources.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/FormComponents/Resources.jsx b/src/components/FormComponents/Resources.jsx index e04bd2be..931e288f 100644 --- a/src/components/FormComponents/Resources.jsx +++ b/src/components/FormComponents/Resources.jsx @@ -130,7 +130,7 @@ const Resources = ({ updateResources, resources, disabled }) => { onTranslateComplete={handleResourceTranslationComplete(i, "name", "Resource name text translated using the Amazon translate service / Texte du nom de la ressource traduit à l'aide du service de traduction Amazon")} fullWidth disabled={disabled} - translateChecked={dist.nameTranslationVerified || false} + translateChecked={resourceItem.nameTranslationVerified || false} translateOnChange={handleResourceTranslateVerifyChange(i, "name")} /> @@ -191,7 +191,7 @@ const Resources = ({ updateResources, resources, disabled }) => { onChange={handleResourceChange("description")} onTranslateComplete={handleResourceTranslationComplete(i, "description", "Resource description text translated using the Amazon translate service / Texte de description de la ressource traduit à l'aide du service de traduction Amazon")} disabled={disabled} - translateChecked={dist.descriptionTranslationVerified || false} + translateChecked={resourceItem.descriptionTranslationVerified || false} translateOnChange={handleResourceTranslateVerifyChange(i, "description")} /> From 86a49e7e59d2ecf022837aac23db40146efb19e0 Mon Sep 17 00:00:00 2001 From: Matthew Foster Date: Wed, 14 Feb 2024 13:28:40 -0800 Subject: [PATCH 25/31] add translation validation boolen and message to bilingual fields --- package.json | 4 +- .../FormComponents/BilingualTextInput.jsx | 43 ++- src/components/FormComponents/Instruments.jsx | 2 + src/components/FormComponents/Platform.jsx | 4 +- src/components/FormComponents/Resources.jsx | 37 +- src/components/Tabs/IdentificationTab.jsx | 14 +- src/eovs.js | 356 +++++++++++++++++ src/eovs.json | 358 ------------------ src/utils/recordToDataCite.js | 1 + 9 files changed, 401 insertions(+), 418 deletions(-) create mode 100644 src/eovs.js delete mode 100644 src/eovs.json diff --git a/package.json b/package.json index 5b0965ee..95551be7 100644 --- a/package.json +++ b/package.json @@ -64,8 +64,8 @@ "react-hot-loader": "^4.12.21" }, "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", + "start": "NODE_OPTIONS=--openssl-legacy-provider react-scripts start", + "build": "NODE_OPTIONS=--openssl-legacy-provider react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "predeploy": "npm run build", diff --git a/src/components/FormComponents/BilingualTextInput.jsx b/src/components/FormComponents/BilingualTextInput.jsx index 35fde56d..d5c34e00 100644 --- a/src/components/FormComponents/BilingualTextInput.jsx +++ b/src/components/FormComponents/BilingualTextInput.jsx @@ -25,18 +25,41 @@ const BilingualTextInput = ({ disabled, error, translationButonDisabled = false, - translateChecked, - translateOnChange, - onTranslateComplete, }) => { const { translate } = useContext(UserContext); const [awaitingTranslation, setAwaitingTranslation] = useState(false); + function handleEvent(e) { - const newData = { ...value, [e.target.name]: e.target.value }; + + const { translations, ...rest } = { ...value}; + const newData = { ...rest, [e.target.name]: e.target.value, + ...( e.target.name === alternateLanguage && + e.target.value && + { translations: value.translations || setTranslationData({}, false) }) + }; const newDataEvent = { target: { name, value: newData } }; onChange(newDataEvent); } + + function setTranslationData(translations, checked) { + return { + ...translations, [alternateLanguage]: { + 'verified': checked, + ...(!checked && {'message': `text translated using the Amazon translate service / texte traduit à l'aide du service de traduction Amazon`}) + } + } + } + + function handleTranslateCheckEvent(e) { + const { checked } = e.target; + const newData = { + ...value, 'translations': setTranslationData(value['translations'], checked) + }; + const newDataEvent = { target: { name, value: newData } }; + onChange(newDataEvent); + } + const { language } = useParams(); let languages; @@ -45,6 +68,9 @@ const BilingualTextInput = ({ if (language === "en") languages = ["en", "fr"]; else languages = ["fr", "en"]; + const alternateLanguage = languages[1]; + const translateChecked = value?.translations?.[alternateLanguage]?.verified || false + return (
{languages.map((lang, i) => ( @@ -53,7 +79,7 @@ const BilingualTextInput = ({ name={lang} fullWidth value={value?.[lang] || ""} - onChange={handleEvent} + onChange={(e) => handleEvent(e)} InputProps={{ startAdornment: ( @@ -92,7 +118,6 @@ const BilingualTextInput = ({ textTooBig } onClick={() => { - const alternateLanguage = languages[1]; setAwaitingTranslation(true); translate({ text: value[lang], fromLang: lang }).then( @@ -105,7 +130,7 @@ const BilingualTextInput = ({ value: translation, }, }); - onTranslateComplete(); + // onTranslateComplete(); } ); }} @@ -115,12 +140,12 @@ const BilingualTextInput = ({ Traduire - {translateOnChange && ( + {value?.[alternateLanguage] && ( handleTranslateCheckEvent(e)} color="primary" /> } diff --git a/src/components/FormComponents/Instruments.jsx b/src/components/FormComponents/Instruments.jsx index c9109ac4..98eed7ed 100644 --- a/src/components/FormComponents/Instruments.jsx +++ b/src/components/FormComponents/Instruments.jsx @@ -149,6 +149,7 @@ const Instruments = ({ Description
diff --git a/src/components/FormComponents/Resources.jsx b/src/components/FormComponents/Resources.jsx index 931e288f..02c25bc8 100644 --- a/src/components/FormComponents/Resources.jsx +++ b/src/components/FormComponents/Resources.jsx @@ -67,36 +67,6 @@ const Resources = ({ updateResources, resources, disabled }) => { updateResources(resources); } - const handleResourceTranslationComplete = (resourceIndex, fieldName, translateMessage) => () => { - const updatedResources = resources.map((resource, index) => { - if (index === resourceIndex) { - return { - ...resource, - [`${fieldName}TranslationMethod`]: translateMessage, - }; - } - return resource; - }); - - updateResources(updatedResources); - }; - - const handleResourceTranslateVerifyChange = (resourceIndex, field) => { - return (e) => { - const { checked } = e.target; - const updatedResources = resources.map((resource, index) => { - if (index === resourceIndex) { - return { - ...resource, - [`${field}TranslationVerified`]: checked, - }; - } - return resource; - }); - updateResources(updatedResources); - }; - } - const nameLabel = ; const descriptionLabel = ; @@ -124,14 +94,12 @@ const Resources = ({ updateResources, resources, disabled }) => { @@ -189,10 +157,7 @@ const Resources = ({ updateResources, resources, disabled }) => { label={descriptionLabel} value={resourceItem.description} onChange={handleResourceChange("description")} - onTranslateComplete={handleResourceTranslationComplete(i, "description", "Resource description text translated using the Amazon translate service / Texte de description de la ressource traduit à l'aide du service de traduction Amazon")} disabled={disabled} - translateChecked={resourceItem.descriptionTranslationVerified || false} - translateOnChange={handleResourceTranslateVerifyChange(i, "description")} /> diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index c707509a..fae699ff 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -13,7 +13,7 @@ import { useParams } from "react-router-dom"; import { OpenInNew, Update } from "@material-ui/icons"; import { En, Fr, I18n } from "../I18n"; import { progressCodes } from "../../isoCodeLists"; -import { eovs, eovCategories } from "../../eovs.json"; +import { eovs, eovCategories } from "../../eovs"; import firebase from "../../firebase"; import BilingualTextInput from "../FormComponents/BilingualTextInput"; @@ -281,12 +281,10 @@ const IdentificationTab = ({
@@ -428,13 +426,11 @@ const IdentificationTab = ({ @@ -992,13 +988,11 @@ const IdentificationTab = ({
diff --git a/src/eovs.js b/src/eovs.js new file mode 100644 index 00000000..78a5095a --- /dev/null +++ b/src/eovs.js @@ -0,0 +1,356 @@ +export const eovCategories = { + "Biogeochemical": { + "en": "Biogeochemical", + "fr": "Biogéochimie", + }, + "Biology and Ecosystems": { + "en": "Biological and Ecosystem", + "fr": "Biologie et écosystèmes", + }, + "Cross-disciplinary": { + "en": "Cross-disciplinary", + "fr": "Interdisciplinaire", + }, + "Physical": { + "en": "Physical", + "fr": "Physique", + }, + "Other": { + "en": "Other", + "fr": "Autre", + }, +}; + +export const eovs = [ + { + "category": "Biogeochemical", + "value": "oxygen", + "label EN": "Oxygen", + "label FR": "Oxygène", + "definition EN": "The amount of dissolved oxygen in seawater.", + "definition FR": "Concentration d'oxygène dissous dans l'eau de mer", + "icon": "dissolved-oxygen.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17473", + }, + { + "category": "Biogeochemical", + "value": "nutrients", + "label EN": "Nutrients", + "label FR": "Nutriments", + "definition EN": "The amount of inorganic nutrients in seawater", + "definition FR": "Concentration des nutriments inorganiques dissous dans l'eau de mer [NO₃, NO₂, PO₄, NH₄, Si(OH)₄]", + "icon": "nutrients.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17474", + }, + { + "category": "Biogeochemical", + "value": "inorganicCarbon", + "label EN": "Inorganic carbon", + "label FR": "Carbone inorganique", + "definition EN": "Total amount of inorganic carbon dissolved in sea water [CO₂, HCO₃-, CO₃²-]", + "definition FR": "Quantité totale de carbone inorganique dissous dans l'eau de mer [CO₂, HCO₃-, CO₃²-]", + "icon": "inorganic-carbon.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17475", + }, + { + "category": "Biogeochemical", + "value": "dissolvedOrganicCarbon", + "label EN": "Dissolved organic carbon", + "label FR": "Carbone organique dissous", + "definition EN": "The amount of dissolved carbon dioxide in seawater", + "definition FR": "Concentration de carbone organique dissous dans l'eau de mer", + "icon": "dissolved-organic-carbon.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17480", + }, + { + "category": "Physical", + "value": "seaSurfaceHeight", + "label EN": "Sea surface height", + "label FR": "Niveau de l'eau", + "definition EN": "The altitude of mean sea level relative to the Earth's geode.", + "definition FR": "Correspond au niveau d'eau mesuré. Les niveaux sont variables en fonction des saisons et des évènements climatique", + "icon": "sea-level.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17465", + }, + { + "category": "Physical", + "value": "seaIce", + "label EN": "Sea ice", + "label FR": "Glace de mer", + "definition EN": "The concentration of ice cover over a specified area and extent", + "definition FR": "La concentration en couverture de glace sur une zone et une étendue spécifiées", + "icon": "sea-ice.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17464", + }, + { + "category": "Physical", + "value": "seaState", + "label EN": "Sea state", + "label FR": "État de la mer", + "definition EN": "Sea State is the characterization of wave and swell, typically in terms of height, wavelength, period, and directional wave energy flux.", + "definition FR": "L'état de la mer est la caractérisation des vagues et de la houle, généralement en termes de hauteur, de longueur d'onde, de période, et le flux d'énergie des ondes directionnelles", + "icon": "sea-state.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17462", + }, + { + "category": "Physical", + "value": "seaSurfaceSalinity", + "label EN": "Sea surface salinity", + "label FR": "Salinité de surface", + "definition EN": "The concentration of dissolved salts in surface seawater.", + "definition FR": "La concentration de sel dissous dans l'eau de mer de surface", + "icon": "salinity.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17470", + }, + { + "category": "Physical", + "value": "seaSurfaceTemperature", + "label EN": "Sea surface temperature", + "label FR": "Température de surface", + "definition EN": "The temperature of surface seawater.", + "definition FR": "La température de l'eau de mer en surface", + "icon": "temperature.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17466", + }, + { + "category": "Physical", + "value": "subSurfaceSalinity", + "label EN": "Subsurface salinity", + "label FR": "Salinité sous la surface", + "definition EN": "The concentration of dissolved salts in subsurface seawater.", + "definition FR": "La concentration de sel dissous dans l'eau de mer sous la surface", + "icon": "salinity.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17471", + }, + { + "category": "Physical", + "value": "subSurfaceTemperature", + "label EN": "Subsurface temperature", + "label FR": "Température sous la surface", + "definition EN": "The temperature of subsurface seawater.", + "definition FR": "La température de l'eau de mer sous la surface", + "icon": "temperature.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17467", + }, + { + "category": "Physical", + "value": "surfaceCurrents", + "label EN": "Surface currents", + "label FR": "Courants de surface", + "definition EN": "The velocity of sea water in surface", + "definition FR": "Vitesse et débit de l'eau en surface", + "icon": "currents.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17468", + }, + { + "category": "Physical", + "value": "subSurfaceCurrents", + "label EN": "Subsurface currents", + "label FR": "Courants sous-marins", + "definition EN": "", + "definition FR": "", + "icon": "currents.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17469", + }, + { + "category": "Other", + "value": "other", + "label EN": "Other", + "label FR": "Autre", + "definition EN": "All data that does not correspond to the current EOVs.", + "definition FR": "Toutes les données qui ne correspondent pas aux EOVs actuels.", + "icon": "eov_other.svg", + }, + { + "category": "Biogeochemical", + "value": "transientTracers", + "label EN": "Transient tracers", + "label FR": "Traceurs transitoires", + "definition EN": "Transient tracers are man-made chemical compounds released to the atmosphere at known quantities that can be used in the ocean to quantify ventilation, transit time distribution and transport time-scales", + "definition FR": "Les traceurs transitoires sont des composés chimiques artificiels rejetés dans l'atmosphère en quantités connues qui peuvent être utilisés dans l'océan pour quantifier la ventilation, la distribution des temps de transit et les échelles de temps de transport.", + "icon": "transient-tracers.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17476", + }, + { + "category": "Biogeochemical", + "value": "particulateMatter", + "label EN": "Particulate matter", + "label FR": "Matière particulaire", + "definition EN": "Total amount of particles (organic & inorganic) suspended in sea water", + "definition FR": "Quantité totale de particules (organiques et inorganiques) en suspension dans l'eau de mer", + "icon": "particulate-matter.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17477", + }, + { + "category": "Biogeochemical", + "value": "nitrousOxide", + "label EN": "Nitrous oxide", + "label FR": "Protoxyde d'azote", + "definition EN": "Nitrous oxide (N2O) is an important climate-relevant trace gas in the Earth’s atmosphere. The ocean-including its coastal areassuch as continental shelves, estuaries and upwelling areas is a major source of N2O and contributesabout 30% to the atmospheric N2O budget.", + "definition FR": "Le protoxyde d'azote ou azote nitreux (N2O) est un important gaz traceur du climat dans l'atmosphère terrestre. L'océan, y compris ses zones côtières telles que les plateaux continentaux, les estuaires et les zones d'upwelling, est une source majeure de N2O. Elle contribue à environ 30 % du bilan atmosphérique en protoxyde d'azote.", + "icon": "nitrous-oxide.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17478", + }, + { + "category": "Biogeochemical", + "value": "stableCarbonIsotopes", + "label EN": "Stable carbon isotopes", + "label FR": "Isotopes stables du carbone", + "definition EN": "The utility of carbon-13 isotope (δ13C, the carbon-13 to carbon-12 isotope ratio; 13C/12C) as a tracer of the ocean’s carbon cycle.", + "definition FR": "L’utilité de l’isotope du carbone-13 (δ13C, le rapport des isotopes du carbone-13 au carbone-12; 13C/12C) comme traceur du cycle du carbone de l’océan.", + "icon": "stable-carbon-isotopes.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17479", + }, + { + "category": "Biology and Ecosystems", + "value": "phytoplanktonBiomassAndDiversity", + "label EN": "Phytoplankton biomass and diversity", + "label FR": "Biomasse et diversité de phytoplancton", + "definition EN": "Characterization of the biological diversity of phytoplankton, their phenology, vertical distribution, and community composition, and their role in ocean biogeochemistry and ecosystem services.", + "definition FR": "Caractérisation de la diversité biologique du phytoplancton, de sa phénologie, de sa distribution verticale et de sa composition communautaire, ainsi que le rôle dans la biogéochimie des océans et les services écosystémiques.", + "icon": "phytoplankton.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17507", + }, + { + "category": "Biology and Ecosystems", + "value": "zooplanktonBiomassAndDiversity", + "label EN": "Zooplankton biomass and diversity", + "label FR": "Biomasse et diversité de zooplancton", + "definition EN": "Zooplankton diversity refers to the number of zooplankton species, taxonomic composition, or community structure within a region. Zooplankton diversity influences ecosystem health and productivity through trophic links.", + "definition FR": "La diversité du zooplancton fait référence au nombre d'espèces de zooplancton, à la composition taxonomique ou à la structure communautaire au sein d'une région. La diversité du zooplancton influence la santé et la productivité de l'écosystème par le biais de liens trophiques.", + "icon": "zooplankton.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17509", + }, + { + "category": "Biology and Ecosystems", + "value": "fishAbundanceAndDistribution", + "label EN": "Fish abundance and distribution", + "label FR": "Abondance et distribution de poissons", + "definition EN": "Fish abundance describes the biomass or numbers of fish in the ocean. It can be reported in terms of species or taxonomic or functional groups (e.g., small pelagic fish, mesopelagic fish, and tunalike species) in an assemblage, population, stock or area, or globally", + "definition FR": "L'abondance des poissons décrit la biomasse ou le nombre de poissons dans l'océan. Il peut être rapporté en termes d'espèces ou de groupes taxonomiques ou fonctionnels (par exemple, petits poissons pélagiques, poissons mésopélagiques et espèces tunal) dans un assemblage, une population, un stock ou une zone, ou à l'échelle mondiale", + "icon": "fish.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17510", + }, + { + "category": "Biology and Ecosystems", + "value": "marineTurtlesBirdsMammalsAbundanceAndDistribution", + "label EN": "Marine turtles, birds, mammals abundance and distribution", + "label FR": "Abondance et distribution de tortues marines, oiseaux et mammifères", + "definition EN": "Abundance refers to the number of individuals (turtles, birds or marine mammals) within a population while distribution refers to\nthe geographic or spatial extent of habitats used by individuals in the population.", + "definition FR": "L'abondance se réfère au nombre d'individus (tortues, oiseaux ou mammifères marins) au sein d'une population tandis que la distribution se réfère à\nl'étendue géographique ou spatiale des habitats utilisés par les individus de la population.", + "icon": "birds-mammals.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17511", + }, + { + "category": "Biology and Ecosystems", + "value": "hardCoralCoverAndComposition", + "label EN": "Hard coral cover and composition", + "label FR": "Composition et couverture des coraux durs", + "definition EN": "Live hard coral cover and the areal extent of a reef are the most important indicators of whether a reef is in a coral-dominated state or not; the composition and diversity of coral taxa is an important index of reef health; coral condition (e.g. bleaching, disease) gives fundamental information on the health of a reef; the size class structure (and recruitment) of hard corals gives fundamental information on the resilience, disturbance history and recovery potential of a reef.", + "definition FR": "La couverture de coraux durs vivants et l'étendue spatiale des récifs sont les indicateurs les plus importants pour savoir si le récif est ou non dominé par les coraux. La composition et la diversité des taxons coralliens sont un indice important de la santé du récif ; l'état des coraux (par exemple le blanchissement, les maladies) donne des informations fondamentales sur la santé du récif ; la structure des classes de taille (et le recrutement) des coraux durs donne des informations fondamentales sur la résilience, l'historique des perturbations et le potentiel de récupération du récif.", + "icon": "birds-mammals.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17512", + }, + { + "category": "Biology and Ecosystems", + "value": "seagrassCoverAndComposition", + "label EN": "Seagrass cover and composition", + "label FR": "Composition et couverture des herbiers marins", + "definition EN": "Characterization of seagrass beds according to species and their cover linked to a spatial distribution.", + "definition FR": "Caractérisation des herbiers marins en fonction des espèces et de leur couverture selon une distribution spatiale.", + "icon": "seagrass.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17513", + }, + { + "category": "Biology and Ecosystems", + "value": "macroalgalCanopyCoverAndComposition", + "label EN": "Macroalgal canopy cover and composition", + "label FR": "Composition et couverture de la canopée de macroalgues", + "definition EN": "Characterization of macroalgal forest according to species and their cover linked to a spatial distribution.", + "definition FR": "Caractérisation des macroalgues en fonction des espèces et de leur couvert selon une distribution spatiale.", + "icon": "macroalgal-canopy.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17515", + }, + { + "category": "Biology and Ecosystems", + "value": "invertebrateAbundanceAndDistribution", + "label EN": "Invertebrate abundance and distribution", + "label FR": "Abondance et distribution d'invertébrés", + "definition EN": "The abundance of invertebrate species describes the biomass or number of individuals in an assemblage and according to a spatial distribution.", + "definition FR": "L'abondance d'espèces invertébrées décrit la biomasse ou le nombre d'individus dans un assemblage et selon une distribution spatiale.", + "icon": "invertebrates.svg", + "emerging": true, + }, + { + "category": "Biology and Ecosystems", + "value": "microbeBiomassAndDiversity", + "label EN": "Microbe biomass and diversity", + "label FR": "Biomasse et diversité microbienne", + "definition EN": "", + "definition FR": "", + "icon": "microbes.svg", + "emerging": true, + }, + { + "category": "Cross-disciplinary", + "value": "oceanColour", + "label EN": "Ocean colour", + "label FR": "Couleur des océans", + "definition EN": "The term \"ocean colour\" refers to the result of absorption and scattering of spectral radiation emanating from the sun. Light interacts with water and suspended or dissolved matter and encompasses a multitude of biological, biogeochemical and ecological factors that form the colour of water.", + "definition FR": "Le terme «couleur de l'océan» se réfère au résultat de l'absorption et de la diffusion du rayonnement spectral émanant du soleil. La lumière interagit avec l'eau et les matières en suspension ou dissoutes et englobe une multitude de facteurs biologiques, biogéochimiques et écologiques qui forment la couleur de l'eau.", + "icon": "ocean-color.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=19959", + }, + { + "category": "Cross-disciplinary", + "value": "oceanSound", + "label EN": "Ocean sound", + "label FR": "Paysage acoustique des océans", + "definition EN": "", + "definition FR": "", + "icon": "ocean-sound.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=22567", + }, + { + "category": "Cross-disciplinary", + "value": "marineDebris", + "label EN": "Marine debris", + "label FR": "Débris marins", + "definition EN": "", + "definition FR": "", + "icon": "", + "emerging": true, + "url": "", + }, + { + "category": "Physical", + "value": "oceanSurfaceHeatFlux", + "label EN": "Ocean surface heat flux", + "label FR": "Flux de chaleur océanique de surface", + "definition EN": "Surface heat flux is the rate of heat exchange, per unit area, passing through the sea surface to the atmosphere. The net heat flux is the sum of the turbulent fluxes (latent and sensitive) and the radiative flux (short and long waves).", + "definition FR": "Le flux de chaleur de surface est le taux d'échange de chaleur, par unité de surface, traversant la surface de la mer jusqu'à l'atmosphère. Le flux de chaleur net est la somme des flux turbulents (latents et sensibles) et du flux radiatif (ondes courtes et longues).", + "icon": "ocean-surface-heat-flux.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17472", + }, + { + "category": "Physical", + "value": "oceanSurfaceStress", + "label EN": "Ocean surface stress", + "label FR": "Contraintes sur la surface océanique", + "definition EN": "Ocean stress is related to lower atmosphere drag and ocean surface dynamics. The magnitude of the stress influences the exchange of energy between the ocean and the atmosphere (evaporation, oxygen, carbon dioxide and other gases).", + "definition FR": "Le stress océanique est lié à la trainée de la basse atmosphère et à la dynamique de surface de l'océan. L'ampleur du stress influence l'échange d'énergie entre l'océan et l'atmosphère (évaporation, oxygène, dioxyde de carbon et gaz autres).", + "icon": "sea-surface-stress.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17463", + }, + { + "category": "Physical", + "value": "oceanBottomPressure", + "label EN": "Ocean Bottom Pressure", + "label FR": "Pression au fond de l'océan", + "definition EN": "Ocean bottom pressure is the total pressure resulting from the weight or mass of the column of seawater and the overlaying atmosphere.", + "definition FR": "La pression au fond de l'océan est la pression totale résultant du poids ou de la masse de la colonne d'eau de mer et de l'atmosphère qui la recouvre.", + "icon": "ocean-bottom-pressure.svg", + "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=32488", + }, +]; + diff --git a/src/eovs.json b/src/eovs.json deleted file mode 100644 index 01fe7631..00000000 --- a/src/eovs.json +++ /dev/null @@ -1,358 +0,0 @@ -{ - "eovCategories": { - "Biogeochemical": { - "en": "Biogeochemical", - "fr": "Biogéochimie" - }, - "Biology and Ecosystems": { - "en": "Biological and Ecosystem", - "fr": "Biologie et écosystèmes" - }, - "Cross-disciplinary": { - "en": "Cross-disciplinary", - "fr": "Interdisciplinaire" - }, - "Physical": { - "en": "Physical", - "fr": "Physique" - }, - "Other": { - "en": "Other", - "fr": "Autre" - } - }, - "eovs": [ - { - "category": "Biogeochemical", - "value": "oxygen", - "label EN": "Oxygen", - "label FR": "Oxygène", - "definition EN": "The amount of dissolved oxygen in seawater.", - "definition FR": "Concentration d'oxygène dissous dans l'eau de mer", - "icon": "dissolved-oxygen.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17473" - }, - { - "category": "Biogeochemical", - "value": "nutrients", - "label EN": "Nutrients", - "label FR": "Nutriments", - "definition EN": "The amount of inorganic nutrients in seawater", - "definition FR": "Concentration des nutriments inorganiques dissous dans l'eau de mer [NO₃, NO₂, PO₄, NH₄, Si(OH)₄]", - "icon": "nutrients.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17474" - }, - { - "category": "Biogeochemical", - "value": "inorganicCarbon", - "label EN": "Inorganic carbon", - "label FR": "Carbone inorganique", - "definition EN": "Total amount of inorganic carbon dissolved in sea water [CO₂, HCO₃-, CO₃²-]", - "definition FR": "Quantité totale de carbone inorganique dissous dans l'eau de mer [CO₂, HCO₃-, CO₃²-]", - "icon": "inorganic-carbon.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17475" - }, - { - "category": "Biogeochemical", - "value": "dissolvedOrganicCarbon", - "label EN": "Dissolved organic carbon", - "label FR": "Carbone organique dissous", - "definition EN": "The amount of dissolved carbon dioxide in seawater", - "definition FR": "Concentration de carbone organique dissous dans l'eau de mer", - "icon": "dissolved-organic-carbon.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17480" - }, - { - "category": "Physical", - "value": "seaSurfaceHeight", - "label EN": "Sea surface height", - "label FR": "Niveau de l'eau", - "definition EN": "The altitude of mean sea level relative to the Earth's geode.", - "definition FR": "Correspond au niveau d'eau mesuré. Les niveaux sont variables en fonction des saisons et des évènements climatique", - "icon": "sea-level.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17465" - }, - { - "category": "Physical", - "value": "seaIce", - "label EN": "Sea ice", - "label FR": "Glace de mer", - "definition EN": "The concentration of ice cover over a specified area and extent", - "definition FR": "La concentration en couverture de glace sur une zone et une étendue spécifiées", - "icon": "sea-ice.svg", - - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17464" - }, - { - "category": "Physical", - "value": "seaState", - "label EN": "Sea state", - "label FR": "État de la mer", - "definition EN": "Sea State is the characterization of wave and swell, typically in terms of height, wavelength, period, and directional wave energy flux.", - "definition FR": "L'état de la mer est la caractérisation des vagues et de la houle, généralement en termes de hauteur, de longueur d'onde, de période, et le flux d'énergie des ondes directionnelles", - "icon": "sea-state.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17462" - }, - { - "category": "Physical", - "value": "seaSurfaceSalinity", - "label EN": "Sea surface salinity", - "label FR": "Salinité de surface", - "definition EN": "The concentration of dissolved salts in surface seawater.", - "definition FR": "La concentration de sel dissous dans l'eau de mer de surface", - "icon": "salinity.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17470" - }, - { - "category": "Physical", - "value": "seaSurfaceTemperature", - "label EN": "Sea surface temperature", - "label FR": "Température de surface", - "definition EN": "The temperature of surface seawater.", - "definition FR": "La température de l'eau de mer en surface", - "icon": "temperature.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17466" - }, - { - "category": "Physical", - "value": "subSurfaceSalinity", - "label EN": "Subsurface salinity", - "label FR": "Salinité sous la surface", - "definition EN": "The concentration of dissolved salts in subsurface seawater.", - "definition FR": "La concentration de sel dissous dans l'eau de mer sous la surface", - "icon": "salinity.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17471" - }, - { - "category": "Physical", - "value": "subSurfaceTemperature", - "label EN": "Subsurface temperature", - "label FR": "Température sous la surface", - "definition EN": "The temperature of subsurface seawater.", - "definition FR": "La température de l'eau de mer sous la surface", - "icon": "temperature.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17467" - }, - { - "category": "Physical", - "value": "surfaceCurrents", - "label EN": "Surface currents", - "label FR": "Courants de surface", - "definition EN": "The velocity of sea water in surface", - "definition FR": "Vitesse et débit de l'eau en surface", - "icon": "currents.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17468" - }, - { - "category": "Physical", - "value": "subSurfaceCurrents", - "label EN": "Subsurface currents", - "label FR": "Courants sous-marins", - "definition EN": "", - "definition FR": "", - "icon": "currents.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17469" - }, - { - "category": "Other", - "value": "other", - "label EN": "Other", - "label FR": "Autre", - "definition EN": "All data that does not correspond to the current EOVs.", - "definition FR": "Toutes les données qui ne correspondent pas aux EOVs actuels.", - "icon": "eov_other.svg" - }, - { - "category": "Biogeochemical", - "value": "transientTracers", - "label EN": "Transient tracers", - "label FR": "Traceurs transitoires", - "definition EN": "Transient tracers are man-made chemical compounds released to the atmosphere at known quantities that can be used in the ocean to quantify ventilation, transit time distribution and transport time-scales", - "definition FR": "Les traceurs transitoires sont des composés chimiques artificiels rejetés dans l'atmosphère en quantités connues qui peuvent être utilisés dans l'océan pour quantifier la ventilation, la distribution des temps de transit et les échelles de temps de transport.", - "icon": "transient-tracers.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17476" - }, - { - "category": "Biogeochemical", - "value": "particulateMatter", - "label EN": "Particulate matter", - "label FR": "Matière particulaire", - "definition EN": "Total amount of particles (organic & inorganic) suspended in sea water", - "definition FR": "Quantité totale de particules (organiques et inorganiques) en suspension dans l'eau de mer", - "icon": "particulate-matter.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17477" - }, - { - "category": "Biogeochemical", - "value": "nitrousOxide", - "label EN": "Nitrous oxide", - "label FR": "Protoxyde d'azote", - "definition EN": "Nitrous oxide (N2O) is an important climate-relevant trace gas in the Earth’s atmosphere. The ocean-including its coastal areassuch as continental shelves, estuaries and upwelling areas is a major source of N2O and contributesabout 30% to the atmospheric N2O budget.", - "definition FR": "Le protoxyde d'azote ou azote nitreux (N2O) est un important gaz traceur du climat dans l'atmosphère terrestre. L'océan, y compris ses zones côtières telles que les plateaux continentaux, les estuaires et les zones d'upwelling, est une source majeure de N2O. Elle contribue à environ 30 % du bilan atmosphérique en protoxyde d'azote.", - "icon": "nitrous-oxide.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17478" - }, - { - "category": "Biogeochemical", - "value": "stableCarbonIsotopes", - "label EN": "Stable carbon isotopes", - "label FR": "Isotopes stables du carbone", - "definition EN": "The utility of carbon-13 isotope (δ13C, the carbon-13 to carbon-12 isotope ratio; 13C/12C) as a tracer of the ocean’s carbon cycle.", - "definition FR": "L’utilité de l’isotope du carbone-13 (δ13C, le rapport des isotopes du carbone-13 au carbone-12; 13C/12C) comme traceur du cycle du carbone de l’océan.", - "icon": "stable-carbon-isotopes.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17479" - }, - - { - "category": "Biology and Ecosystems", - "value": "phytoplanktonBiomassAndDiversity", - "label EN": "Phytoplankton biomass and diversity", - "label FR": "Biomasse et diversité de phytoplancton", - "definition EN": "Characterization of the biological diversity of phytoplankton, their phenology, vertical distribution, and community composition, and their role in ocean biogeochemistry and ecosystem services.", - "definition FR": "Caractérisation de la diversité biologique du phytoplancton, de sa phénologie, de sa distribution verticale et de sa composition communautaire, ainsi que le rôle dans la biogéochimie des océans et les services écosystémiques.", - "icon": "phytoplankton.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17507" - }, - { - "category": "Biology and Ecosystems", - "value": "zooplanktonBiomassAndDiversity", - "label EN": "Zooplankton biomass and diversity", - "label FR": "Biomasse et diversité de zooplancton", - "definition EN": "Zooplankton diversity refers to the number of zooplankton species, taxonomic composition, or community structure within a region. Zooplankton diversity influences ecosystem health and productivity through trophic links.", - "definition FR": "La diversité du zooplancton fait référence au nombre d'espèces de zooplancton, à la composition taxonomique ou à la structure communautaire au sein d'une région. La diversité du zooplancton influence la santé et la productivité de l'écosystème par le biais de liens trophiques.", - "icon": "zooplankton.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17509" - }, - { - "category": "Biology and Ecosystems", - "value": "fishAbundanceAndDistribution", - "label EN": "Fish abundance and distribution", - "label FR": "Abondance et distribution de poissons", - "definition EN": "Fish abundance describes the biomass or numbers of fish in the ocean. It can be reported in terms of species or taxonomic or functional groups (e.g., small pelagic fish, mesopelagic fish, and tunalike species) in an assemblage, population, stock or area, or globally", - "definition FR": "L'abondance des poissons décrit la biomasse ou le nombre de poissons dans l'océan. Il peut être rapporté en termes d'espèces ou de groupes taxonomiques ou fonctionnels (par exemple, petits poissons pélagiques, poissons mésopélagiques et espèces tunal) dans un assemblage, une population, un stock ou une zone, ou à l'échelle mondiale", - "icon": "fish.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17510" - }, - { - "category": "Biology and Ecosystems", - "value": "marineTurtlesBirdsMammalsAbundanceAndDistribution", - "label EN": "Marine turtles, birds, mammals abundance and distribution", - "label FR": "Abondance et distribution de tortues marines, oiseaux et mammifères", - "definition EN": "Abundance refers to the number of individuals (turtles, birds or marine mammals) within a population while distribution refers to\nthe geographic or spatial extent of habitats used by individuals in the population.", - "definition FR": "L'abondance se réfère au nombre d'individus (tortues, oiseaux ou mammifères marins) au sein d'une population tandis que la distribution se réfère à\nl'étendue géographique ou spatiale des habitats utilisés par les individus de la population.", - "icon": "birds-mammals.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17511" - }, - { - "category": "Biology and Ecosystems", - "value": "hardCoralCoverAndComposition", - "label EN": "Hard coral cover and composition", - "label FR": "Composition et couverture des coraux durs", - "definition EN": "Live hard coral cover and the areal extent of a reef are the most important indicators of whether a reef is in a coral-dominated state or not; the composition and diversity of coral taxa is an important index of reef health; coral condition (e.g. bleaching, disease) gives fundamental information on the health of a reef; the size class structure (and recruitment) of hard corals gives fundamental information on the resilience, disturbance history and recovery potential of a reef.", - "definition FR": "La couverture de coraux durs vivants et l'étendue spatiale des récifs sont les indicateurs les plus importants pour savoir si le récif est ou non dominé par les coraux. La composition et la diversité des taxons coralliens sont un indice important de la santé du récif ; l'état des coraux (par exemple le blanchissement, les maladies) donne des informations fondamentales sur la santé du récif ; la structure des classes de taille (et le recrutement) des coraux durs donne des informations fondamentales sur la résilience, l'historique des perturbations et le potentiel de récupération du récif.", - "icon": "birds-mammals.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17512" - }, - { - "category": "Biology and Ecosystems", - "value": "seagrassCoverAndComposition", - "label EN": "Seagrass cover and composition", - "label FR": "Composition et couverture des herbiers marins", - "definition EN": "Characterization of seagrass beds according to species and their cover linked to a spatial distribution.", - "definition FR": "Caractérisation des herbiers marins en fonction des espèces et de leur couverture selon une distribution spatiale.", - "icon": "seagrass.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17513" - }, - { - "category": "Biology and Ecosystems", - "value": "macroalgalCanopyCoverAndComposition", - "label EN": "Macroalgal canopy cover and composition", - "label FR": "Composition et couverture de la canopée de macroalgues", - "definition EN": "Characterization of macroalgal forest according to species and their cover linked to a spatial distribution.", - "definition FR": "Caractérisation des macroalgues en fonction des espèces et de leur couvert selon une distribution spatiale.", - "icon": "macroalgal-canopy.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17515" - }, - { - "category": "Biology and Ecosystems", - "value": "invertebrateAbundanceAndDistribution", - "label EN": "Invertebrate abundance and distribution", - "label FR": "Abondance et distribution d'invertébrés", - "definition EN": "The abundance of invertebrate species describes the biomass or number of individuals in an assemblage and according to a spatial distribution.", - "definition FR": "L'abondance d'espèces invertébrées décrit la biomasse ou le nombre d'individus dans un assemblage et selon une distribution spatiale.", - "icon": "invertebrates.svg", - "emerging": true - }, - { - "category": "Biology and Ecosystems", - "value": "microbeBiomassAndDiversity", - "label EN": "Microbe biomass and diversity", - "label FR": "Biomasse et diversité microbienne", - "definition EN": "", - "definition FR": "", - "icon": "microbes.svg", - "emerging": true - }, - { - "category": "Cross-disciplinary", - "value": "oceanColour", - "label EN": "Ocean colour", - "label FR": "Couleur des océans", - "definition EN": "The term \"ocean colour\" refers to the result of absorption and scattering of spectral radiation emanating from the sun. Light interacts with water and suspended or dissolved matter and encompasses a multitude of biological, biogeochemical and ecological factors that form the colour of water.", - "definition FR": "Le terme «couleur de l'océan» se réfère au résultat de l'absorption et de la diffusion du rayonnement spectral émanant du soleil. La lumière interagit avec l'eau et les matières en suspension ou dissoutes et englobe une multitude de facteurs biologiques, biogéochimiques et écologiques qui forment la couleur de l'eau.", - "icon": "ocean-color.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=19959" - }, - { - "category": "Cross-disciplinary", - "value": "oceanSound", - "label EN": "Ocean sound", - "label FR": "Paysage acoustique des océans", - "definition EN": "", - "definition FR": "", - "icon": "ocean-sound.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=22567" - }, - { - "category": "Cross-disciplinary", - "value": "marineDebris", - "label EN": "Marine debris", - "label FR": "Débris marins", - "definition EN": "", - "definition FR": "", - "icon": "", - "emerging": true, - "url": "" - }, - { - "category": "Physical", - "value": "oceanSurfaceHeatFlux", - "label EN": "Ocean surface heat flux", - "label FR": "Flux de chaleur océanique de surface", - "definition EN": "Surface heat flux is the rate of heat exchange, per unit area, passing through the sea surface to the atmosphere. The net heat flux is the sum of the turbulent fluxes (latent and sensitive) and the radiative flux (short and long waves).", - "definition FR": "Le flux de chaleur de surface est le taux d'échange de chaleur, par unité de surface, traversant la surface de la mer jusqu'à l'atmosphère. Le flux de chaleur net est la somme des flux turbulents (latents et sensibles) et du flux radiatif (ondes courtes et longues).", - "icon": "ocean-surface-heat-flux.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17472" - }, - { - "category": "Physical", - "value": "oceanSurfaceStress", - "label EN": "Ocean surface stress", - "label FR": "Contraintes sur la surface océanique", - "definition EN": "Ocean stress is related to lower atmosphere drag and ocean surface dynamics. The magnitude of the stress influences the exchange of energy between the ocean and the atmosphere (evaporation, oxygen, carbon dioxide and other gases).", - "definition FR": "Le stress océanique est lié à la trainée de la basse atmosphère et à la dynamique de surface de l'océan. L'ampleur du stress influence l'échange d'énergie entre l'océan et l'atmosphère (évaporation, oxygène, dioxyde de carbon et gaz autres).", - "icon": "sea-surface-stress.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=17463" - }, - { - "category": "Physical", - "value": "oceanBottomPressure", - "label EN": "Ocean Bottom Pressure", - "label FR": "Pression au fond de l'océan", - "definition EN": "Ocean bottom pressure is the total pressure resulting from the weight or mass of the column of seawater and the overlaying atmosphere.", - "definition FR": "La pression au fond de l'océan est la pression totale résultant du poids ou de la masse de la colonne d'eau de mer et de l'atmosphère qui la recouvre.", - "icon": "ocean-bottom-pressure.svg", - "url": "https://www.goosocean.org/index.php?option=com_oe&task=viewDocumentRecord&docID=32488" - } - ] -} diff --git a/src/utils/recordToDataCite.js b/src/utils/recordToDataCite.js index 9503625b..2bd8b0c7 100644 --- a/src/utils/recordToDataCite.js +++ b/src/utils/recordToDataCite.js @@ -224,6 +224,7 @@ function recordToDataCite(metadata, language, region) { mappedDataCiteObject.data.attributes.rightsList = rightsList; // Add descriptions from the abstract field + delete metadata.abstract.translations mappedDataCiteObject.data.attributes.descriptions = Object.entries( metadata.abstract ).map(([lang, description]) => ({ From 3c9c8f53316702fa4a35a2831bc44371639d970a Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Thu, 22 Feb 2024 14:55:59 -0800 Subject: [PATCH 26/31] update build test action --- .github/workflows/run-build-tests.yaml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/run-build-tests.yaml b/.github/workflows/run-build-tests.yaml index 3840813c..f2b56865 100644 --- a/.github/workflows/run-build-tests.yaml +++ b/.github/workflows/run-build-tests.yaml @@ -1,5 +1,6 @@ name: Run Build and Tests -on: push +on: push: + workflow_dispatch: jobs: build: @@ -7,23 +8,15 @@ jobs: strategy: matrix: - node-version: [12.x] + node-version: [16.x] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- + cache: 'npm' # Enable automatic caching for npm - run: npm ci - run: npm run build --if-present - run: npm run test From 7002364501d01c2f5a4c3acbf6a3f3cf4572652a Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Thu, 22 Feb 2024 14:57:16 -0800 Subject: [PATCH 27/31] update build test action --- .github/workflows/run-build-tests.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-build-tests.yaml b/.github/workflows/run-build-tests.yaml index f2b56865..ee888c54 100644 --- a/.github/workflows/run-build-tests.yaml +++ b/.github/workflows/run-build-tests.yaml @@ -1,5 +1,6 @@ name: Run Build and Tests -on: push: +on: + push: workflow_dispatch: jobs: From e28be4feb0b253a18f3d1cd1b3647a3a2d503ee0 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Thu, 22 Feb 2024 15:16:00 -0800 Subject: [PATCH 28/31] remove node options from script --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 95551be7..5b0965ee 100644 --- a/package.json +++ b/package.json @@ -64,8 +64,8 @@ "react-hot-loader": "^4.12.21" }, "scripts": { - "start": "NODE_OPTIONS=--openssl-legacy-provider react-scripts start", - "build": "NODE_OPTIONS=--openssl-legacy-provider react-scripts build", + "start": "react-scripts start", + "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "predeploy": "npm run build", From 059803b9ee6018b4a88868c13ae091ee283a5a9d Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Thu, 22 Feb 2024 17:11:45 -0800 Subject: [PATCH 29/31] remove unused handlers --- src/components/FormComponents/Platform.jsx | 2 +- src/components/Pages/MetadataForm.jsx | 14 -------------- src/components/Tabs/IdentificationTab.jsx | 2 -- src/components/Tabs/PlatformTab.jsx | 4 ---- 4 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/components/FormComponents/Platform.jsx b/src/components/FormComponents/Platform.jsx index 5f308073..2ecf6e23 100644 --- a/src/components/FormComponents/Platform.jsx +++ b/src/components/FormComponents/Platform.jsx @@ -12,7 +12,7 @@ import { validateField } from "../../utils/validate"; import SelectInput from "./SelectInput"; import platforms from "../../platforms.json"; -const Platform = ({ record, handleUpdateRecord, handleTranslationComplete, handleTranslateVerifyChange, disabled }) => { +const Platform = ({ record, handleUpdateRecord, disabled }) => { const { language = "en" } = useParams(); const platformsSorted = Object.values(platforms).sort((a, b) => diff --git a/src/components/Pages/MetadataForm.jsx b/src/components/Pages/MetadataForm.jsx index a0b92be8..7e66e65f 100644 --- a/src/components/Pages/MetadataForm.jsx +++ b/src/components/Pages/MetadataForm.jsx @@ -231,18 +231,6 @@ class MetadataForm extends FormClassTemplate { })); }; - handleTranslationComplete = (fieldName, translateMessage) => () => { - const translationMethodField = `${fieldName}TranslationMethod`; - this.updateRecord(translationMethodField)(translateMessage); - }; - - handleTranslateVerifyChange = (fieldName) => { - return (e) => { - const { checked } = e.target; - this.updateRecord(fieldName)(checked); - }; - } - saveUpdateContact(contact) { const { contactID } = contact; const { match } = this.props; @@ -390,8 +378,6 @@ class MetadataForm extends FormClassTemplate { record, handleUpdateRecord: this.handleUpdateRecord, updateRecord: this.updateRecord, - handleTranslationComplete: this.handleTranslationComplete, - handleTranslateVerifyChange: this.handleTranslateVerifyChange, }; const percentValidInt = Math.round(percentValid(record) * 100); return loading ? ( diff --git a/src/components/Tabs/IdentificationTab.jsx b/src/components/Tabs/IdentificationTab.jsx index fae699ff..68a5703c 100644 --- a/src/components/Tabs/IdentificationTab.jsx +++ b/src/components/Tabs/IdentificationTab.jsx @@ -40,8 +40,6 @@ const IdentificationTab = ({ record, handleUpdateRecord, updateRecord, - handleTranslationComplete, - handleTranslateVerifyChange, projects, }) => { const { createDraftDoi, updateDraftDoi, deleteDraftDoi, getDoiStatus } = useContext(UserContext); diff --git a/src/components/Tabs/PlatformTab.jsx b/src/components/Tabs/PlatformTab.jsx index 374ba52a..82f8c1bc 100644 --- a/src/components/Tabs/PlatformTab.jsx +++ b/src/components/Tabs/PlatformTab.jsx @@ -11,8 +11,6 @@ const PlatformTab = ({ disabled, record, handleUpdateRecord, - handleTranslationComplete, - handleTranslateVerifyChange, updateRecord, }) => { const noPlatform = record.noPlatform && record.noPlatform !== "false"; @@ -89,8 +87,6 @@ const PlatformTab = ({ From 7c3ff0b75eeaa469fe6e781f67af6330f346ca10 Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Mon, 26 Feb 2024 16:23:52 -0800 Subject: [PATCH 30/31] Ensure translations field exists on component mount/load --- .../FormComponents/BilingualTextInput.jsx | 114 +++++++++++------- 1 file changed, 70 insertions(+), 44 deletions(-) diff --git a/src/components/FormComponents/BilingualTextInput.jsx b/src/components/FormComponents/BilingualTextInput.jsx index d5c34e00..a5a82d90 100644 --- a/src/components/FormComponents/BilingualTextInput.jsx +++ b/src/components/FormComponents/BilingualTextInput.jsx @@ -1,4 +1,4 @@ -import React, { useContext, useState } from "react"; +import React, { useContext, useState, useEffect } from "react"; import { Button, InputAdornment, @@ -29,47 +29,73 @@ const BilingualTextInput = ({ const { translate } = useContext(UserContext); const [awaitingTranslation, setAwaitingTranslation] = useState(false); + const { language } = useParams(); + let languages; - function handleEvent(e) { + const textSizeByes = new Blob([value?.[language]]).size; + const textTooBig = textSizeByes >= MAX_AWS_TRANSLATE_SIZE; - const { translations, ...rest } = { ...value}; - const newData = { ...rest, [e.target.name]: e.target.value, - ...( e.target.name === alternateLanguage && - e.target.value && - { translations: value.translations || setTranslationData({}, false) }) - }; - const newDataEvent = { target: { name, value: newData } }; - onChange(newDataEvent); - } + if (language === "en") languages = ["en", "fr"]; + else languages = ["fr", "en"]; + const alternateLanguage = languages[1]; + const translateChecked = + value?.translations?.[alternateLanguage]?.verified || false; function setTranslationData(translations, checked) { return { - ...translations, [alternateLanguage]: { - 'verified': checked, - ...(!checked && {'message': `text translated using the Amazon translate service / texte traduit à l'aide du service de traduction Amazon`}) - } - } + ...translations, + [alternateLanguage]: { + verified: checked, + ...(!checked && { + message: `text translated using the Amazon translate service / texte traduit à l'aide du service de traduction Amazon`, + }), + }, + }; + } + + function handleEvent(e) { + const { translations, ...rest } = { ...value }; + const newData = { + ...rest, + [e.target.name]: e.target.value, + ...(e.target.name === alternateLanguage && + e.target.value && { + translations: value.translations || setTranslationData({}, false), + }), + }; + const newDataEvent = { target: { name, value: newData } }; + onChange(newDataEvent); } - + function handleTranslateCheckEvent(e) { const { checked } = e.target; - const newData = { - ...value, 'translations': setTranslationData(value['translations'], checked) + const newData = { + ...value, + translations: setTranslationData(value.translations, checked), }; const newDataEvent = { target: { name, value: newData } }; onChange(newDataEvent); } - const { language } = useParams(); - let languages; - - const textSizeByes = new Blob([value?.[language]]).size; - const textTooBig = textSizeByes >= MAX_AWS_TRANSLATE_SIZE; - - if (language === "en") languages = ["en", "fr"]; - else languages = ["fr", "en"]; - const alternateLanguage = languages[1]; - const translateChecked = value?.translations?.[alternateLanguage]?.verified || false + // Ensure translations field exists on component mount/load + useEffect(() => { + if (value && !value.translations) { + const hasTranslations = value.en && value.fr; + if (hasTranslations) { + const updatedValue = { + ...value, + translations: { + fr: { + verified: false, + message: + "text translated using the Amazon translate service / texte traduit à l'aide du service de traduction Amazon", + }, + }, + }; + onChange({ target: { name, value: updatedValue } }); + } + } + }, []); return (
@@ -142,22 +168,22 @@ const BilingualTextInput = ({ {value?.[alternateLanguage] && ( handleTranslateCheckEvent(e)} - color="primary" - /> - } - label={ - - I have verified this translation - J'ai vérifié cette traduction - - } - /> + control={ + handleTranslateCheckEvent(e)} + color="primary" + /> + } + label={ + + I have verified this translation + J'ai vérifié cette traduction + + } + /> )} - + {textTooBig && ( From ed7314f674332d059bf90a9d18b0df69390cab4c Mon Sep 17 00:00:00 2001 From: Austen Sorochak Date: Mon, 26 Feb 2024 16:32:41 -0800 Subject: [PATCH 31/31] add variables to useEffect dependency array --- src/components/FormComponents/BilingualTextInput.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/FormComponents/BilingualTextInput.jsx b/src/components/FormComponents/BilingualTextInput.jsx index a5a82d90..e57f1aed 100644 --- a/src/components/FormComponents/BilingualTextInput.jsx +++ b/src/components/FormComponents/BilingualTextInput.jsx @@ -95,7 +95,7 @@ const BilingualTextInput = ({ onChange({ target: { name, value: updatedValue } }); } } - }, []); + }, [name, onChange, value]); return (