From 47d2abbd79d6800a9e5e003447b34b564ba19c3e Mon Sep 17 00:00:00 2001 From: farres1 Date: Thu, 8 Feb 2024 10:47:56 +0000 Subject: [PATCH 01/17] Add data version radio options --- eq-author-api/schema/typeDefs.js | 1 + .../App/settings/DataVersionSelect/index.js | 102 ++++++++++++++++++ eq-author/src/App/settings/SettingsPage.js | 15 ++- .../src/App/settings/SettingsPage.test.js | 1 + .../graphql/fragments/questionnaire.graphql | 1 + 5 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 eq-author/src/App/settings/DataVersionSelect/index.js diff --git a/eq-author-api/schema/typeDefs.js b/eq-author-api/schema/typeDefs.js index 8c348f761b..cc0deff9a0 100644 --- a/eq-author-api/schema/typeDefs.js +++ b/eq-author-api/schema/typeDefs.js @@ -1311,6 +1311,7 @@ input UpdateQuestionnaireInput { editors: [ID!] isPublic: Boolean permission: String + dataVersion: String } diff --git a/eq-author/src/App/settings/DataVersionSelect/index.js b/eq-author/src/App/settings/DataVersionSelect/index.js new file mode 100644 index 0000000000..bee1ae2dd4 --- /dev/null +++ b/eq-author/src/App/settings/DataVersionSelect/index.js @@ -0,0 +1,102 @@ +import React from "react"; +import PropTypes from "prop-types"; +import styled from "styled-components"; +import { useMutation } from "@apollo/react-hooks"; +import { colors } from "constants/theme.js"; + +import { Input } from "components/Forms"; +import { + RadioLabel, + RadioField, + RadioDescription as RadioTitle, +} from "components/Radio"; + +import UPDATE_QUESTIONNAIRE_MUTATION from "graphql/updateQuestionnaire.graphql"; + +const StyledRadioTitle = styled(RadioTitle)` + font-size: 1em; + letter-spacing: 0; + margin-left: 2.3em; + color: ${colors.text}; + margin-bottom: 0.3em; +`; + +const RadioDescription = styled.span` + font-size: 0.8em; + letter-spacing: 0; + margin-left: 2.9em; + color: ${colors.text}; +`; + +const StyledRadioLabel = styled(RadioLabel)` + min-width: 22.5em; + width: fit-content; +`; + +const dataVersionOptions = [ + { + value: "1", + title: "Data version 1", + description: + "Enables downstream processing of older questionnaires without complex features", + }, + { + value: "3", + title: "Data version 3", + description: + "Enables downstream processing of newer questionnaires with complex features", + }, +]; + +const DataVersionOption = ({ questionnaireId, value, selected, children }) => { + const [updateQuestionnaire] = useMutation(UPDATE_QUESTIONNAIRE_MUTATION); + return ( + + + updateQuestionnaire({ + variables: { input: { id: questionnaireId, dataVersion: value } }, + }) + } + /> + {children} + + ); +}; + +const DataVersionSelect = ({ questionnaireId, selectedDataVersion }) => { + return ( + + {dataVersionOptions.map(({ value, title, description }) => ( + + {title} + {description} + + ))} + + ); +}; + +DataVersionOption.propTypes = { + questionnaireId: PropTypes.string, + value: PropTypes.string, + selected: PropTypes.bool, + children: PropTypes.node, +}; + +DataVersionSelect.propTypes = { + questionnaireId: PropTypes.string, + shortName: PropTypes.string, + selectedDataVersion: PropTypes.string, +}; + +export default DataVersionSelect; diff --git a/eq-author/src/App/settings/SettingsPage.js b/eq-author/src/App/settings/SettingsPage.js index 6e5b709073..caba6b44d6 100644 --- a/eq-author/src/App/settings/SettingsPage.js +++ b/eq-author/src/App/settings/SettingsPage.js @@ -11,6 +11,8 @@ import updateQuestionnaireMutation from "graphql/updateQuestionnaire.graphql"; import updateQuestionnaireIntroductionMutation from "graphql/updateQuestionnaireIntroduction.graphql"; import ThemeSelect from "./ThemeSelect"; +import LegalBasisSelect from "./LegalBasisSelect"; +import DataVersionSelect from "./DataVersionSelect"; import { Grid, Column } from "components/Grid"; import Header from "components/EditorLayout/Header"; @@ -23,7 +25,6 @@ import { FORM_TYPE_ERRORS, EQ_ID_ERRORS, } from "constants/validationMessages"; -import LegalBasisSelect from "./LegalBasisSelect"; import { reduceMultipleSpaces } from "utils/reduceMultipleSpaces"; @@ -110,6 +111,7 @@ const SettingsPage = ({ questionnaire }) => { formType: initialFormType, theme, legalBasis, + dataVersion, } = questionnaire; const showOnHub = introduction?.showOnHub; @@ -397,6 +399,17 @@ const SettingsPage = ({ questionnaire }) => { selectedLegalBasis={legalBasis} /> + + + + There are two processing methods for questionnaire data: + data version 1 and data version 3. + + + diff --git a/eq-author/src/App/settings/SettingsPage.test.js b/eq-author/src/App/settings/SettingsPage.test.js index 035e3fd56f..71fc7a8b45 100644 --- a/eq-author/src/App/settings/SettingsPage.test.js +++ b/eq-author/src/App/settings/SettingsPage.test.js @@ -52,6 +52,7 @@ describe("Settings page", () => { legalBasis: "NOTICE_1", theme: "business", displayName: "Roar", + dataVersion: "1", introduction: { id: "spyro-1", showOnHub: false, diff --git a/eq-author/src/graphql/fragments/questionnaire.graphql b/eq-author/src/graphql/fragments/questionnaire.graphql index c9fabca7c6..901a2015eb 100644 --- a/eq-author/src/graphql/fragments/questionnaire.graphql +++ b/eq-author/src/graphql/fragments/questionnaire.graphql @@ -15,6 +15,7 @@ fragment Questionnaire on Questionnaire { type shortTitle displayName + dataVersion introduction { id showOnHub From 56ac0169ee8f5048e837912713a65b8bbedf9bd8 Mon Sep 17 00:00:00 2001 From: farres1 Date: Thu, 8 Feb 2024 12:01:47 +0000 Subject: [PATCH 02/17] Disable data version one option when complex features enabled --- .../schema/resolvers/utils/setDataVersion.js | 4 ++++ eq-author-api/schema/typeDefs.js | 1 + .../App/settings/DataVersionSelect/index.js | 23 ++++++++++++++++--- eq-author/src/App/settings/SettingsPage.js | 2 ++ eq-author/src/App/settings/index.js | 1 + eq-author/src/components/Radio/index.js | 3 ++- .../graphql/fragments/questionnaire.graphql | 1 + 7 files changed, 31 insertions(+), 4 deletions(-) diff --git a/eq-author-api/schema/resolvers/utils/setDataVersion.js b/eq-author-api/schema/resolvers/utils/setDataVersion.js index 86ccfe7d7e..4876e4c6f0 100644 --- a/eq-author-api/schema/resolvers/utils/setDataVersion.js +++ b/eq-author-api/schema/resolvers/utils/setDataVersion.js @@ -2,14 +2,17 @@ const { getAnswers } = require("./answerGetters"); const setDataVersion = ({ questionnaire }) => { questionnaire.dataVersion = "1"; + questionnaire.dataVersionThreeRequired = false; if (questionnaire.collectionLists?.lists?.length) { questionnaire.dataVersion = "3"; + questionnaire.dataVersionThreeRequired = true; return; } if (questionnaire.supplementaryData) { questionnaire.dataVersion = "3"; + questionnaire.dataVersionThreeRequired = true; return; } @@ -18,6 +21,7 @@ const setDataVersion = ({ questionnaire }) => { return answer.options?.some((option) => { if (option.dynamicAnswer) { questionnaire.dataVersion = "3"; + questionnaire.dataVersionThreeRequired = true; return true; } return false; diff --git a/eq-author-api/schema/typeDefs.js b/eq-author-api/schema/typeDefs.js index cc0deff9a0..0cd3422f5e 100644 --- a/eq-author-api/schema/typeDefs.js +++ b/eq-author-api/schema/typeDefs.js @@ -62,6 +62,7 @@ type Questionnaire { navigation: Boolean hub: Boolean dataVersion: String + dataVersionThreeRequired: Boolean createdAt: DateTime updatedAt: DateTime createdBy: User! diff --git a/eq-author/src/App/settings/DataVersionSelect/index.js b/eq-author/src/App/settings/DataVersionSelect/index.js index bee1ae2dd4..05531998a1 100644 --- a/eq-author/src/App/settings/DataVersionSelect/index.js +++ b/eq-author/src/App/settings/DataVersionSelect/index.js @@ -48,15 +48,25 @@ const dataVersionOptions = [ }, ]; -const DataVersionOption = ({ questionnaireId, value, selected, children }) => { +const DataVersionOption = ({ + questionnaireId, + value, + selected, + dataVersionThreeRequired, + children, +}) => { const [updateQuestionnaire] = useMutation(UPDATE_QUESTIONNAIRE_MUTATION); return ( - + updateQuestionnaire({ variables: { input: { id: questionnaireId, dataVersion: value } }, @@ -68,7 +78,11 @@ const DataVersionOption = ({ questionnaireId, value, selected, children }) => { ); }; -const DataVersionSelect = ({ questionnaireId, selectedDataVersion }) => { +const DataVersionSelect = ({ + questionnaireId, + selectedDataVersion, + dataVersionThreeRequired, +}) => { return ( {dataVersionOptions.map(({ value, title, description }) => ( @@ -77,6 +91,7 @@ const DataVersionSelect = ({ questionnaireId, selectedDataVersion }) => { value={value} selected={value === selectedDataVersion} questionnaireId={questionnaireId} + dataVersionThreeRequired={dataVersionThreeRequired} > {title} {description} @@ -90,6 +105,7 @@ DataVersionOption.propTypes = { questionnaireId: PropTypes.string, value: PropTypes.string, selected: PropTypes.bool, + dataVersionThreeRequired: PropTypes.bool, children: PropTypes.node, }; @@ -97,6 +113,7 @@ DataVersionSelect.propTypes = { questionnaireId: PropTypes.string, shortName: PropTypes.string, selectedDataVersion: PropTypes.string, + dataVersionThreeRequired: PropTypes.bool, }; export default DataVersionSelect; diff --git a/eq-author/src/App/settings/SettingsPage.js b/eq-author/src/App/settings/SettingsPage.js index caba6b44d6..5b444b093c 100644 --- a/eq-author/src/App/settings/SettingsPage.js +++ b/eq-author/src/App/settings/SettingsPage.js @@ -112,6 +112,7 @@ const SettingsPage = ({ questionnaire }) => { theme, legalBasis, dataVersion, + dataVersionThreeRequired, } = questionnaire; const showOnHub = introduction?.showOnHub; @@ -408,6 +409,7 @@ const SettingsPage = ({ questionnaire }) => { diff --git a/eq-author/src/App/settings/index.js b/eq-author/src/App/settings/index.js index c1373452c1..8bfae5cc3f 100644 --- a/eq-author/src/App/settings/index.js +++ b/eq-author/src/App/settings/index.js @@ -16,6 +16,7 @@ export default [ variables={{ input: { questionnaireId: props.match.params.questionnaireId }, }} + fetchPolicy="cache-and-network" > {({ loading, error, data }) => { if (loading) { diff --git a/eq-author/src/components/Radio/index.js b/eq-author/src/components/Radio/index.js index a1525145cd..f941b7baf1 100644 --- a/eq-author/src/components/Radio/index.js +++ b/eq-author/src/components/Radio/index.js @@ -16,13 +16,14 @@ export const RadioLabel = styled.label` } border: 1px solid ${colors.bordersLight}; flex: 1 1 33.3333333%; - cursor: pointer; + cursor: ${(props) => !props.disabled && `pointer`}; display: flex; flex-direction: column; color: ${colors.textLight}; position: relative; background: ${(props) => props.selected ? `${colors.lighterGrey}` : `${colors.white}`}; + ${(props) => props.disabled && "opacity: 0.6;"} &:hover { box-shadow: 0 0 0 1px ${colors.blue}; diff --git a/eq-author/src/graphql/fragments/questionnaire.graphql b/eq-author/src/graphql/fragments/questionnaire.graphql index 901a2015eb..fabe0aa594 100644 --- a/eq-author/src/graphql/fragments/questionnaire.graphql +++ b/eq-author/src/graphql/fragments/questionnaire.graphql @@ -16,6 +16,7 @@ fragment Questionnaire on Questionnaire { shortTitle displayName dataVersion + dataVersionThreeRequired introduction { id showOnHub From c2fda3e43e1f43c0672c7b12984d45dd62386462 Mon Sep 17 00:00:00 2001 From: farres1 Date: Thu, 8 Feb 2024 12:05:09 +0000 Subject: [PATCH 03/17] Prevent updating data version to one automatically when complex features deleted --- eq-author-api/schema/resolvers/utils/setDataVersion.js | 1 - 1 file changed, 1 deletion(-) diff --git a/eq-author-api/schema/resolvers/utils/setDataVersion.js b/eq-author-api/schema/resolvers/utils/setDataVersion.js index 4876e4c6f0..b51898fc7a 100644 --- a/eq-author-api/schema/resolvers/utils/setDataVersion.js +++ b/eq-author-api/schema/resolvers/utils/setDataVersion.js @@ -1,7 +1,6 @@ const { getAnswers } = require("./answerGetters"); const setDataVersion = ({ questionnaire }) => { - questionnaire.dataVersion = "1"; questionnaire.dataVersionThreeRequired = false; if (questionnaire.collectionLists?.lists?.length) { From da8a5a3ace52f1c778f8a8f1e59d209e97d06bbb Mon Sep 17 00:00:00 2001 From: farres1 Date: Thu, 8 Feb 2024 12:28:35 +0000 Subject: [PATCH 04/17] Set default data version to three when questionnaire is created --- eq-author-api/schema/resolvers/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eq-author-api/schema/resolvers/base.js b/eq-author-api/schema/resolvers/base.js index 3447c9865c..624aeaf5ce 100644 --- a/eq-author-api/schema/resolvers/base.js +++ b/eq-author-api/schema/resolvers/base.js @@ -149,7 +149,7 @@ const createNewQuestionnaire = (input) => { qcodes: true, navigation: false, hub: false, - dataVersion: "1", + dataVersion: "3", createdAt: new Date(), metadata: [], sections: [createSection()], From b9a323bfe3ecb15abda7e577a22a16af17dd67f3 Mon Sep 17 00:00:00 2001 From: farres1 Date: Thu, 8 Feb 2024 12:53:49 +0000 Subject: [PATCH 05/17] Disable data version radio options based on array for future data versions --- eq-author-api/schema/resolvers/base.js | 1 + .../schema/resolvers/utils/setDataVersion.js | 8 ++++---- eq-author-api/schema/typeDefs.js | 2 +- .../src/App/settings/DataVersionSelect/index.js | 14 +++++++------- eq-author/src/App/settings/SettingsPage.js | 4 ++-- .../src/graphql/fragments/questionnaire.graphql | 2 +- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/eq-author-api/schema/resolvers/base.js b/eq-author-api/schema/resolvers/base.js index 624aeaf5ce..6d79a425ed 100644 --- a/eq-author-api/schema/resolvers/base.js +++ b/eq-author-api/schema/resolvers/base.js @@ -150,6 +150,7 @@ const createNewQuestionnaire = (input) => { navigation: false, hub: false, dataVersion: "3", + allowableDataVersions: ["1", "3"], createdAt: new Date(), metadata: [], sections: [createSection()], diff --git a/eq-author-api/schema/resolvers/utils/setDataVersion.js b/eq-author-api/schema/resolvers/utils/setDataVersion.js index b51898fc7a..7feb1e67d1 100644 --- a/eq-author-api/schema/resolvers/utils/setDataVersion.js +++ b/eq-author-api/schema/resolvers/utils/setDataVersion.js @@ -1,17 +1,17 @@ const { getAnswers } = require("./answerGetters"); const setDataVersion = ({ questionnaire }) => { - questionnaire.dataVersionThreeRequired = false; + questionnaire.allowableDataVersions = ["1", "3"]; if (questionnaire.collectionLists?.lists?.length) { questionnaire.dataVersion = "3"; - questionnaire.dataVersionThreeRequired = true; + questionnaire.allowableDataVersions = ["3"]; return; } if (questionnaire.supplementaryData) { questionnaire.dataVersion = "3"; - questionnaire.dataVersionThreeRequired = true; + questionnaire.allowableDataVersions = ["3"]; return; } @@ -20,7 +20,7 @@ const setDataVersion = ({ questionnaire }) => { return answer.options?.some((option) => { if (option.dynamicAnswer) { questionnaire.dataVersion = "3"; - questionnaire.dataVersionThreeRequired = true; + questionnaire.allowableDataVersions = ["3"]; return true; } return false; diff --git a/eq-author-api/schema/typeDefs.js b/eq-author-api/schema/typeDefs.js index 0cd3422f5e..f77ab93712 100644 --- a/eq-author-api/schema/typeDefs.js +++ b/eq-author-api/schema/typeDefs.js @@ -62,7 +62,7 @@ type Questionnaire { navigation: Boolean hub: Boolean dataVersion: String - dataVersionThreeRequired: Boolean + allowableDataVersions: [String] createdAt: DateTime updatedAt: DateTime createdBy: User! diff --git a/eq-author/src/App/settings/DataVersionSelect/index.js b/eq-author/src/App/settings/DataVersionSelect/index.js index 05531998a1..db10fa35ac 100644 --- a/eq-author/src/App/settings/DataVersionSelect/index.js +++ b/eq-author/src/App/settings/DataVersionSelect/index.js @@ -52,21 +52,21 @@ const DataVersionOption = ({ questionnaireId, value, selected, - dataVersionThreeRequired, + allowableDataVersions, children, }) => { const [updateQuestionnaire] = useMutation(UPDATE_QUESTIONNAIRE_MUTATION); return ( updateQuestionnaire({ variables: { input: { id: questionnaireId, dataVersion: value } }, @@ -81,7 +81,7 @@ const DataVersionOption = ({ const DataVersionSelect = ({ questionnaireId, selectedDataVersion, - dataVersionThreeRequired, + allowableDataVersions, }) => { return ( @@ -91,7 +91,7 @@ const DataVersionSelect = ({ value={value} selected={value === selectedDataVersion} questionnaireId={questionnaireId} - dataVersionThreeRequired={dataVersionThreeRequired} + allowableDataVersions={allowableDataVersions} > {title} {description} @@ -105,7 +105,7 @@ DataVersionOption.propTypes = { questionnaireId: PropTypes.string, value: PropTypes.string, selected: PropTypes.bool, - dataVersionThreeRequired: PropTypes.bool, + allowableDataVersions: PropTypes.arrayOf(PropTypes.string), children: PropTypes.node, }; @@ -113,7 +113,7 @@ DataVersionSelect.propTypes = { questionnaireId: PropTypes.string, shortName: PropTypes.string, selectedDataVersion: PropTypes.string, - dataVersionThreeRequired: PropTypes.bool, + allowableDataVersions: PropTypes.arrayOf(PropTypes.string), }; export default DataVersionSelect; diff --git a/eq-author/src/App/settings/SettingsPage.js b/eq-author/src/App/settings/SettingsPage.js index 5b444b093c..70ba2c2213 100644 --- a/eq-author/src/App/settings/SettingsPage.js +++ b/eq-author/src/App/settings/SettingsPage.js @@ -112,7 +112,7 @@ const SettingsPage = ({ questionnaire }) => { theme, legalBasis, dataVersion, - dataVersionThreeRequired, + allowableDataVersions, } = questionnaire; const showOnHub = introduction?.showOnHub; @@ -409,7 +409,7 @@ const SettingsPage = ({ questionnaire }) => { diff --git a/eq-author/src/graphql/fragments/questionnaire.graphql b/eq-author/src/graphql/fragments/questionnaire.graphql index fabe0aa594..f1946cafc5 100644 --- a/eq-author/src/graphql/fragments/questionnaire.graphql +++ b/eq-author/src/graphql/fragments/questionnaire.graphql @@ -16,7 +16,7 @@ fragment Questionnaire on Questionnaire { shortTitle displayName dataVersion - dataVersionThreeRequired + allowableDataVersions introduction { id showOnHub From 6c56a4a1f7a8171b25aa6245b01423e43ae7a966 Mon Sep 17 00:00:00 2001 From: farres1 Date: Thu, 8 Feb 2024 13:01:33 +0000 Subject: [PATCH 06/17] Add all data versions constant --- eq-author-api/constants/allDataVersions.js | 1 + eq-author-api/schema/resolvers/base.js | 3 ++- eq-author-api/schema/resolvers/utils/setDataVersion.js | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 eq-author-api/constants/allDataVersions.js diff --git a/eq-author-api/constants/allDataVersions.js b/eq-author-api/constants/allDataVersions.js new file mode 100644 index 0000000000..d8bc8f353f --- /dev/null +++ b/eq-author-api/constants/allDataVersions.js @@ -0,0 +1 @@ +module.exports = ["1", "3"]; diff --git a/eq-author-api/schema/resolvers/base.js b/eq-author-api/schema/resolvers/base.js index 6d79a425ed..364ac39b9f 100644 --- a/eq-author-api/schema/resolvers/base.js +++ b/eq-author-api/schema/resolvers/base.js @@ -26,6 +26,7 @@ const { AWAITING_APPROVAL, UPDATES_REQUIRED, } = require("../../constants/publishStatus"); +const allDataVersions = require("../../constants/allDataVersions"); const { DURATION_LOOKUP } = require("../../constants/durationTypes"); const { @@ -150,7 +151,7 @@ const createNewQuestionnaire = (input) => { navigation: false, hub: false, dataVersion: "3", - allowableDataVersions: ["1", "3"], + allowableDataVersions: allDataVersions, createdAt: new Date(), metadata: [], sections: [createSection()], diff --git a/eq-author-api/schema/resolvers/utils/setDataVersion.js b/eq-author-api/schema/resolvers/utils/setDataVersion.js index 7feb1e67d1..a821fee695 100644 --- a/eq-author-api/schema/resolvers/utils/setDataVersion.js +++ b/eq-author-api/schema/resolvers/utils/setDataVersion.js @@ -1,7 +1,8 @@ const { getAnswers } = require("./answerGetters"); +const allDataVersions = require("../../../constants/allDataVersions"); const setDataVersion = ({ questionnaire }) => { - questionnaire.allowableDataVersions = ["1", "3"]; + questionnaire.allowableDataVersions = allDataVersions; if (questionnaire.collectionLists?.lists?.length) { questionnaire.dataVersion = "3"; From 4fc088840ad8641c2fcd3c01e5ba5fd42117ce29 Mon Sep 17 00:00:00 2001 From: farres1 Date: Thu, 8 Feb 2024 14:59:25 +0000 Subject: [PATCH 07/17] Update snapshots --- .../Label/__snapshots__/Label.test.js.snap | 8 ++++++-- .../Forms/Label/__snapshots__/Label.test.js.snap | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/eq-author/src/components-themed/Label/__snapshots__/Label.test.js.snap b/eq-author/src/components-themed/Label/__snapshots__/Label.test.js.snap index f904698666..0fa2695fc4 100644 --- a/eq-author/src/components-themed/Label/__snapshots__/Label.test.js.snap +++ b/eq-author/src/components-themed/Label/__snapshots__/Label.test.js.snap @@ -21,11 +21,15 @@ exports[`components-themed/radio Input should render correctly 1`] = ` "rules": Array [ "padding:1em;border-radius:0.25em;&:not(:last-of-type){margin-bottom:0.8em;}border:1px solid ", "#d6d8da", - ";flex:1 1 33.3333333%;cursor:pointer;display:flex;flex-direction:column;color:", + ";flex:1 1 33.3333333%;cursor:", + [Function], + ";display:flex;flex-direction:column;color:", "#666666", ";position:relative;background:", [Function], - ";&:hover{box-shadow:0 0 0 1px ", + ";", + [Function], + " &:hover{box-shadow:0 0 0 1px ", "#3B7A9E", ";}&:focus-within{border-color:", "#3B7A9E", diff --git a/eq-author/src/components/Forms/Label/__snapshots__/Label.test.js.snap b/eq-author/src/components/Forms/Label/__snapshots__/Label.test.js.snap index c21d9e4f13..9f94a40350 100644 --- a/eq-author/src/components/Forms/Label/__snapshots__/Label.test.js.snap +++ b/eq-author/src/components/Forms/Label/__snapshots__/Label.test.js.snap @@ -12,11 +12,15 @@ exports[`components/Forms/Input should render correctly 1`] = ` "rules": Array [ "padding:1em;border-radius:0.25em;&:not(:last-of-type){margin-bottom:0.8em;}border:1px solid ", "#d6d8da", - ";flex:1 1 33.3333333%;cursor:pointer;display:flex;flex-direction:column;color:", + ";flex:1 1 33.3333333%;cursor:", + [Function], + ";display:flex;flex-direction:column;color:", "#666666", ";position:relative;background:", [Function], - ";&:hover{box-shadow:0 0 0 1px ", + ";", + [Function], + " &:hover{box-shadow:0 0 0 1px ", "#3B7A9E", ";}&:focus-within{border-color:", "#3B7A9E", From b3bc3cf5cda47f2b8f9e32912c5486019f4a7137 Mon Sep 17 00:00:00 2001 From: farres1 Date: Fri, 9 Feb 2024 07:46:59 +0000 Subject: [PATCH 08/17] Add tests for setting data version for dynamic answers --- .../schema/tests/questionnaire.test.js | 64 +++++++++++++++++++ .../tests/utils/contextBuilder/index.js | 3 +- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/eq-author-api/schema/tests/questionnaire.test.js b/eq-author-api/schema/tests/questionnaire.test.js index d8c1b21256..eb55a4cb58 100644 --- a/eq-author-api/schema/tests/questionnaire.test.js +++ b/eq-author-api/schema/tests/questionnaire.test.js @@ -1,4 +1,5 @@ const { last, findIndex, find } = require("lodash"); +const { CHECKBOX, RADIO } = require("../../constants/answerTypes"); jest.mock("node-fetch"); const fetch = require("node-fetch"); @@ -35,6 +36,9 @@ const { setQuestionnaireLocked, updateSubmission, } = require("../../tests/utils/contextBuilder/questionnaire"); +const { + updateOption, +} = require("../../tests/utils/contextBuilder/option/updateOption"); const { createAnswer, @@ -164,6 +168,66 @@ describe("questionnaire", () => { expect(queriedShortTitleQuestionnaire.displayName).toEqual("short title"); }); + it("should set data version to 3 and remove data version 1 from allowable data versions if questionnaire contains dynamic answers", async () => { + const ctx = await buildContext({ + supplementaryData: null, + sections: [ + { + folders: [ + { + pages: [ + { + answers: [ + { + type: CHECKBOX, + options: [ + { + label: "checkbox-option-1", + }, + ], + }, + ], + }, + { + answers: [ + { + type: RADIO, + options: [ + { + id: "radio-option-1", + }, + ], + }, + ], + }, + ], + }, + ], + }, + ], + }); + + expect(ctx.questionnaire.dataVersion).toEqual("3"); + expect(ctx.questionnaire.allowableDataVersions).toEqual(["1", "3"]); + + const option = + ctx.questionnaire.sections[0].folders[0].pages[1].answers[0].options[0]; + + const update = { + id: option.id, + label: "Dynamic option 1", + description: "Dynamic option description", + value: "dynamic-option-1", + qCode: "dynamic-option-1", + dynamicAnswer: true, + }; + + updateOption(ctx, update); + + expect(ctx.questionnaire.dataVersion).toEqual("3"); + expect(ctx.questionnaire.allowableDataVersions).toEqual(["3"]); + }); + describe("starring", () => { it("should throw user input error if questionnaire ID doesn't exist", () => { expect( diff --git a/eq-author-api/tests/utils/contextBuilder/index.js b/eq-author-api/tests/utils/contextBuilder/index.js index 42306040c3..2d405d7eac 100644 --- a/eq-author-api/tests/utils/contextBuilder/index.js +++ b/eq-author-api/tests/utils/contextBuilder/index.js @@ -73,7 +73,8 @@ const buildContext = async (questionnaireConfig, userConfig = {}) => { const { questionnaire } = ctx; ctx.questionnaire.sections = []; ctx.comments = comments || {}; - ctx.questionnaire.supplementaryData = supplementaryData || {}; + ctx.questionnaire.supplementaryData = + supplementaryData === null ? null : supplementaryData || {}; if (Array.isArray(sections)) { for (let section of sections) { From dde4676149fd53dd1ed8b4735133566cba6bddbd Mon Sep 17 00:00:00 2001 From: farres1 Date: Fri, 9 Feb 2024 09:18:43 +0000 Subject: [PATCH 09/17] Add data version select tests --- .../App/settings/DataVersionSelect/index.js | 1 + .../settings/DataVersionSelect/index.test.js | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 eq-author/src/App/settings/DataVersionSelect/index.test.js diff --git a/eq-author/src/App/settings/DataVersionSelect/index.js b/eq-author/src/App/settings/DataVersionSelect/index.js index db10fa35ac..78b7f57d25 100644 --- a/eq-author/src/App/settings/DataVersionSelect/index.js +++ b/eq-author/src/App/settings/DataVersionSelect/index.js @@ -72,6 +72,7 @@ const DataVersionOption = ({ variables: { input: { id: questionnaireId, dataVersion: value } }, }) } + data-test={`data-version-input-${value}`} /> {children} diff --git a/eq-author/src/App/settings/DataVersionSelect/index.test.js b/eq-author/src/App/settings/DataVersionSelect/index.test.js new file mode 100644 index 0000000000..1907016587 --- /dev/null +++ b/eq-author/src/App/settings/DataVersionSelect/index.test.js @@ -0,0 +1,57 @@ +import React from "react"; +import { render, fireEvent } from "tests/utils/rtl"; +import { useMutation } from "@apollo/react-hooks"; + +import DataVersionSelect from "."; + +jest.mock("@apollo/react-hooks", () => ({ + useMutation: jest.fn(() => [() => null]), +})); + +describe("DataVersionSelect", () => { + let props; + const updateQuestionnaire = jest.fn(); + + beforeEach(() => { + props = { + questionnaireId: "questionnaire-1", + selectedDataVersion: "1", + allowableDataVersions: ["1", "3"], + }; + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + const renderDataVersionSelect = (props) => { + return render(); + }; + + it("should render", () => { + const { getByText } = renderDataVersionSelect(props); + expect(getByText("Data version 1")).toBeTruthy(); + expect(getByText("Data version 3")).toBeTruthy(); + }); + + it("should update questionnaire data version", () => { + useMutation.mockImplementation(jest.fn(() => [updateQuestionnaire])); + const { getByTestId } = renderDataVersionSelect(props); + + fireEvent.click(getByTestId("data-version-input-3")); + expect(updateQuestionnaire).toHaveBeenCalledWith({ + variables: { + input: { id: "questionnaire-1", dataVersion: "3" }, + }, + }); + }); + + it("should disable data version option if not in allowable data versions", () => { + props.selectedDataVersion = "3"; + props.allowableDataVersions = ["3"]; + const { getByTestId } = renderDataVersionSelect(props); + + expect(getByTestId("data-version-input-1")).toBeDisabled(); + expect(getByTestId("data-version-input-3")).not.toBeDisabled(); + }); +}); From 7ec8578eb3edb91cd8543c714e666a78d4f03f42 Mon Sep 17 00:00:00 2001 From: farres1 Date: Fri, 9 Feb 2024 09:37:00 +0000 Subject: [PATCH 10/17] Fix data version only set for dynamic options when option is deleted --- eq-author-api/schema/resolvers/base.js | 3 +++ eq-author-api/schema/resolvers/pages/index.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/eq-author-api/schema/resolvers/base.js b/eq-author-api/schema/resolvers/base.js index 364ac39b9f..c77225062d 100644 --- a/eq-author-api/schema/resolvers/base.js +++ b/eq-author-api/schema/resolvers/base.js @@ -660,6 +660,7 @@ const Resolvers = { const pages = getPages(ctx); onSectionDeleted(ctx, removedSection, pages); + setDataVersion(ctx); if (!ctx.questionnaire.sections.length) { ctx.questionnaire.sections.push(createSection()); @@ -729,6 +730,7 @@ const Resolvers = { const pages = getPages(ctx); onFolderDeleted(ctx, removedFolder, pages); + setDataVersion(ctx); if (!section.folders.length) { section.folders.push(createFolder()); @@ -864,6 +866,7 @@ const Resolvers = { const deletedAnswer = first(remove(page.answers, { id: input.id })); onAnswerDeleted(ctx, page, deletedAnswer, pages); + setDataVersion(ctx); return page; }), diff --git a/eq-author-api/schema/resolvers/pages/index.js b/eq-author-api/schema/resolvers/pages/index.js index 3163d5dc83..b6e1df7fa4 100644 --- a/eq-author-api/schema/resolvers/pages/index.js +++ b/eq-author-api/schema/resolvers/pages/index.js @@ -20,6 +20,7 @@ const { createQuestionPage } = require("./questionPage"); const deleteFirstPageSkipConditions = require("../../../src/businessLogic/deleteFirstPageSkipConditions"); const deleteLastPageRouting = require("../../../src/businessLogic/deleteLastPageRouting"); const onFolderDeleted = require("../../../src/businessLogic/onFolderDeleted"); +const { setDataVersion } = require("../utils/setDataVersion"); const Resolvers = {}; @@ -86,6 +87,7 @@ Resolvers.Mutation = { deleteFirstPageSkipConditions(ctx); deleteLastPageRouting(ctx); + setDataVersion(ctx); return section; }), From 6bfbf2115be4e415e6d08f7fba4e347465dcc055 Mon Sep 17 00:00:00 2001 From: farres1 Date: Mon, 26 Feb 2024 14:15:29 +0000 Subject: [PATCH 11/17] Add migration for allowable data versions --- .../migrations/addAllowableDataVersions.js | 17 +++++++++++++++++ eq-author-api/migrations/index.js | 1 + 2 files changed, 18 insertions(+) create mode 100644 eq-author-api/migrations/addAllowableDataVersions.js diff --git a/eq-author-api/migrations/addAllowableDataVersions.js b/eq-author-api/migrations/addAllowableDataVersions.js new file mode 100644 index 0000000000..04ebdbcec6 --- /dev/null +++ b/eq-author-api/migrations/addAllowableDataVersions.js @@ -0,0 +1,17 @@ +const { getOptions } = require("../schema/resolvers/utils"); + +module.exports = (questionnaire) => { + const allQuestionnaireOptions = getOptions({ questionnaire }); + + if (questionnaire.collectionLists?.lists?.length > 0) { + questionnaire.allowableDataVersions = ["3"]; + } else if (questionnaire.supplementaryData) { + questionnaire.allowableDataVersions = ["3"]; + } else if (allQuestionnaireOptions?.some((option) => option.dynamicAnswer)) { + questionnaire.allowableDataVersions = ["3"]; + } else { + questionnaire.allowableDataVersions = ["1", "3"]; + } + + return questionnaire; +}; diff --git a/eq-author-api/migrations/index.js b/eq-author-api/migrations/index.js index 0eb6f51efe..65a48a73e3 100644 --- a/eq-author-api/migrations/index.js +++ b/eq-author-api/migrations/index.js @@ -53,6 +53,7 @@ const migrations = [ require("./addFieldsToListCollectorFolderContents"), require("./addAdditonalContentsToAddItemPage"), require("./updateHealthThemeToPandemicMonitoring"), + require("./addAllowableDataVersions"), ]; const currentVersion = migrations.length; From 0df8c892271a39d09d94701266650836adeb5355 Mon Sep 17 00:00:00 2001 From: farres1 Date: Tue, 27 Feb 2024 08:37:22 +0000 Subject: [PATCH 12/17] Add migration tests --- .../addAllowableDataVersions.test.js | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 eq-author-api/migrations/addAllowableDataVersions.test.js diff --git a/eq-author-api/migrations/addAllowableDataVersions.test.js b/eq-author-api/migrations/addAllowableDataVersions.test.js new file mode 100644 index 0000000000..c25a93471a --- /dev/null +++ b/eq-author-api/migrations/addAllowableDataVersions.test.js @@ -0,0 +1,77 @@ +const addAllowableDataVersions = require("./addAllowableDataVersions"); + +describe("addAllowableDataVersions", () => { + it("should add allowableDataVersions with data version 3 when questionnaire has collection list", () => { + const questionnaire = { + id: "questionnaire-1", + title: "Questionnaire 1", + collectionLists: { + lists: [{ id: "list-1" }], + }, + }; + + const updatedQuestionnaire = addAllowableDataVersions(questionnaire); + + expect(updatedQuestionnaire.allowableDataVersions).toEqual(["3"]); + }); + + it("should add allowableDataVersions with data version 3 when questionnaire has supplementary data", () => { + const questionnaire = { + id: "questionnaire-1", + title: "Questionnaire 1", + supplementaryData: { id: "supplementary-data-1" }, + }; + + const updatedQuestionnaire = addAllowableDataVersions(questionnaire); + + expect(updatedQuestionnaire.allowableDataVersions).toEqual(["3"]); + }); + + it("should add allowableDataVersions with data version 3 when questionnaire has dynamic answer", () => { + const questionnaire = { + id: "questionnaire-1", + title: "Questionnaire 1", + sections: [ + { + id: "section-1", + folders: [ + { + id: "folder-1", + pages: [ + { + id: "page-1", + answers: [ + { + id: "answer-1", + options: [ + { + id: "option-1", + dynamicAnswer: true, + }, + ], + }, + ], + }, + ], + }, + ], + }, + ], + }; + + const updatedQuestionnaire = addAllowableDataVersions(questionnaire); + + expect(updatedQuestionnaire.allowableDataVersions).toEqual(["3"]); + }); + + it("should add allowableDataVersions with data versions 1 and 3 when questionnaire has no collection lists, supplementary data or dynamic answers", () => { + const questionnaire = { + id: "questionnaire-1", + title: "Questionnaire 1", + }; + + const updatedQuestionnaire = addAllowableDataVersions(questionnaire); + + expect(updatedQuestionnaire.allowableDataVersions).toEqual(["1", "3"]); + }); +}); From e6f03ad94fc5dad931e4d37b867d6cb4a91cb8ff Mon Sep 17 00:00:00 2001 From: farres1 Date: Tue, 27 Feb 2024 09:58:55 +0000 Subject: [PATCH 13/17] Set data version when importing content into questionnaire --- eq-author-api/schema/resolvers/importing.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eq-author-api/schema/resolvers/importing.js b/eq-author-api/schema/resolvers/importing.js index 0f59327a64..d599f3b1e1 100644 --- a/eq-author-api/schema/resolvers/importing.js +++ b/eq-author-api/schema/resolvers/importing.js @@ -16,6 +16,8 @@ const { UserInputError } = require("apollo-server-express"); const { createMutation } = require("./createMutation"); +const { setDataVersion } = require("./utils"); + module.exports = { Mutation: { importQuestions: createMutation( @@ -91,6 +93,7 @@ module.exports = { ...strippedPages.map((page) => createFolder({ pages: [page] })) ); } + setDataVersion(ctx); return section; } @@ -178,6 +181,8 @@ module.exports = { destinationSections.splice(insertionIndex, 0, ...strippedSections); ctx.questionnaire.hub = ctx.questionnaire.sections.length > 1; + setDataVersion(ctx); + return destinationSections; } ), From 1ef3ae8c73bb8fecce139eb2ba47c6a7eff97038 Mon Sep 17 00:00:00 2001 From: farres1 Date: Tue, 27 Feb 2024 13:28:47 +0000 Subject: [PATCH 14/17] Fix data version accessibility error --- .../App/settings/DataVersionSelect/index.js | 55 ++++++++++++++----- eq-author/src/App/settings/SettingsPage.js | 5 -- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/eq-author/src/App/settings/DataVersionSelect/index.js b/eq-author/src/App/settings/DataVersionSelect/index.js index 78b7f57d25..18581db071 100644 --- a/eq-author/src/App/settings/DataVersionSelect/index.js +++ b/eq-author/src/App/settings/DataVersionSelect/index.js @@ -33,6 +33,26 @@ const StyledRadioLabel = styled(RadioLabel)` width: fit-content; `; +const Caption = styled.p` + margin-top: 0.2em; + margin-bottom: 0.6em; + font-size: 0.85em; +`; + +const StyledFieldset = styled.fieldset` + border: none; + padding: 0; + margin: 0; +`; + +const StyledLegend = styled.legend` + display: block; + padding: 0; + font-weight: bold; + color: ${colors.text}; + line-height: 1.3; +`; + const dataVersionOptions = [ { value: "1", @@ -85,20 +105,27 @@ const DataVersionSelect = ({ allowableDataVersions, }) => { return ( - - {dataVersionOptions.map(({ value, title, description }) => ( - - {title} - {description} - - ))} - + + Data version + + There are two processing methods for questionnaire data: data version 1 + and data version 3. + + + {dataVersionOptions.map(({ value, title, description }) => ( + + {title} + {description} + + ))} + + ); }; diff --git a/eq-author/src/App/settings/SettingsPage.js b/eq-author/src/App/settings/SettingsPage.js index 70ba2c2213..eb78cd1675 100644 --- a/eq-author/src/App/settings/SettingsPage.js +++ b/eq-author/src/App/settings/SettingsPage.js @@ -401,11 +401,6 @@ const SettingsPage = ({ questionnaire }) => { /> - - - There are two processing methods for questionnaire data: - data version 1 and data version 3. - Date: Tue, 27 Feb 2024 15:54:06 +0000 Subject: [PATCH 15/17] Fix test missing fields --- .../src/App/settings/SettingsPage.test.js | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/eq-author/src/App/settings/SettingsPage.test.js b/eq-author/src/App/settings/SettingsPage.test.js index 71fc7a8b45..8c55bc4baa 100644 --- a/eq-author/src/App/settings/SettingsPage.test.js +++ b/eq-author/src/App/settings/SettingsPage.test.js @@ -53,9 +53,30 @@ describe("Settings page", () => { theme: "business", displayName: "Roar", dataVersion: "1", + allowableDataVersions: ["1", "3"], introduction: { id: "spyro-1", + title: "Introduction", showOnHub: false, + contactDetailsPhoneNumber: "", + contactDetailsEmailAddress: "", + contactDetailsEmailSubject: "", + contactDetailsIncludeRuRef: true, + description: "", + additionalGuidancePanelSwitch: false, + additionalGuidancePanel: "", + previewQuestions: false, + disallowPreviewQuestions: false, + secondaryTitle: "", + secondaryDescription: "", + tertiaryTitle: "", + tertiaryDescription: "", + validationErrorInfo: { + id: "validation-error-info-introduction", + errors: [], + totalCount: 0, + __typename: "ValidationErrorInfo", + }, __typename: "QuestionnaireIntroduction", }, createdBy: { @@ -222,14 +243,10 @@ describe("Settings page", () => { queryWasCalled = true; return { data: { - updateQuestionnaireIntroductionMutation: { - ...mockQuestionnaire, - hub: true, - navigation: false, - introduction: { - showOnHub: true, - }, - __typename: "Questionnaire", + updateQuestionnaireIntroduction: { + ...mockQuestionnaire.introduction, + showOnHub: true, + __typename: "QuestionnaireIntroduction", }, }, }; From e08ea46ba7ed893b7366a0cb99852bca43a2ad17 Mon Sep 17 00:00:00 2001 From: farres1 Date: Wed, 28 Feb 2024 09:38:30 +0000 Subject: [PATCH 16/17] Update migration to set data version --- .../migrations/addAllowableDataVersions.js | 11 ++++++----- .../migrations/addAllowableDataVersions.test.js | 13 +++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/eq-author-api/migrations/addAllowableDataVersions.js b/eq-author-api/migrations/addAllowableDataVersions.js index 04ebdbcec6..76d83d60d1 100644 --- a/eq-author-api/migrations/addAllowableDataVersions.js +++ b/eq-author-api/migrations/addAllowableDataVersions.js @@ -3,11 +3,12 @@ const { getOptions } = require("../schema/resolvers/utils"); module.exports = (questionnaire) => { const allQuestionnaireOptions = getOptions({ questionnaire }); - if (questionnaire.collectionLists?.lists?.length > 0) { - questionnaire.allowableDataVersions = ["3"]; - } else if (questionnaire.supplementaryData) { - questionnaire.allowableDataVersions = ["3"]; - } else if (allQuestionnaireOptions?.some((option) => option.dynamicAnswer)) { + if ( + questionnaire.collectionLists?.lists?.length > 0 || + questionnaire.supplementaryData || + allQuestionnaireOptions?.some((option) => option.dynamicAnswer) + ) { + questionnaire.dataVersion = "3"; questionnaire.allowableDataVersions = ["3"]; } else { questionnaire.allowableDataVersions = ["1", "3"]; diff --git a/eq-author-api/migrations/addAllowableDataVersions.test.js b/eq-author-api/migrations/addAllowableDataVersions.test.js index c25a93471a..ad8672709a 100644 --- a/eq-author-api/migrations/addAllowableDataVersions.test.js +++ b/eq-author-api/migrations/addAllowableDataVersions.test.js @@ -1,7 +1,7 @@ const addAllowableDataVersions = require("./addAllowableDataVersions"); describe("addAllowableDataVersions", () => { - it("should add allowableDataVersions with data version 3 when questionnaire has collection list", () => { + it("should set dataVersion to 3 and add allowableDataVersions with data version 3 when questionnaire has collection list", () => { const questionnaire = { id: "questionnaire-1", title: "Questionnaire 1", @@ -12,10 +12,11 @@ describe("addAllowableDataVersions", () => { const updatedQuestionnaire = addAllowableDataVersions(questionnaire); + expect(updatedQuestionnaire.dataVersion).toEqual("3"); expect(updatedQuestionnaire.allowableDataVersions).toEqual(["3"]); }); - it("should add allowableDataVersions with data version 3 when questionnaire has supplementary data", () => { + it("should set dataVersion to 3 and add allowableDataVersions with data version 3 when questionnaire has supplementary data", () => { const questionnaire = { id: "questionnaire-1", title: "Questionnaire 1", @@ -24,10 +25,11 @@ describe("addAllowableDataVersions", () => { const updatedQuestionnaire = addAllowableDataVersions(questionnaire); + expect(updatedQuestionnaire.dataVersion).toEqual("3"); expect(updatedQuestionnaire.allowableDataVersions).toEqual(["3"]); }); - it("should add allowableDataVersions with data version 3 when questionnaire has dynamic answer", () => { + it("should set dataVersion to 3 and add allowableDataVersions with data version 3 when questionnaire has dynamic answer", () => { const questionnaire = { id: "questionnaire-1", title: "Questionnaire 1", @@ -61,17 +63,20 @@ describe("addAllowableDataVersions", () => { const updatedQuestionnaire = addAllowableDataVersions(questionnaire); + expect(updatedQuestionnaire.dataVersion).toEqual("3"); expect(updatedQuestionnaire.allowableDataVersions).toEqual(["3"]); }); - it("should add allowableDataVersions with data versions 1 and 3 when questionnaire has no collection lists, supplementary data or dynamic answers", () => { + it("should add allowableDataVersions with data versions 1 and 3 without updating dataVersion when questionnaire has no collection lists, supplementary data or dynamic answers", () => { const questionnaire = { id: "questionnaire-1", title: "Questionnaire 1", + dataVersion: "1", }; const updatedQuestionnaire = addAllowableDataVersions(questionnaire); + expect(updatedQuestionnaire.dataVersion).toEqual("1"); expect(updatedQuestionnaire.allowableDataVersions).toEqual(["1", "3"]); }); }); From c2efa1a4dcd9b2c353f40075feff23203367f894 Mon Sep 17 00:00:00 2001 From: farres1 Date: Wed, 28 Feb 2024 10:29:05 +0000 Subject: [PATCH 17/17] Move data version options to constants file --- .../App/settings/DataVersionSelect/index.js | 19 +++---------------- .../src/constants/data-version-options.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 eq-author/src/constants/data-version-options.js diff --git a/eq-author/src/App/settings/DataVersionSelect/index.js b/eq-author/src/App/settings/DataVersionSelect/index.js index 18581db071..1fc79d870e 100644 --- a/eq-author/src/App/settings/DataVersionSelect/index.js +++ b/eq-author/src/App/settings/DataVersionSelect/index.js @@ -13,6 +13,8 @@ import { import UPDATE_QUESTIONNAIRE_MUTATION from "graphql/updateQuestionnaire.graphql"; +import DATA_VERSION_OPTIONS from "constants/data-version-options"; + const StyledRadioTitle = styled(RadioTitle)` font-size: 1em; letter-spacing: 0; @@ -53,21 +55,6 @@ const StyledLegend = styled.legend` line-height: 1.3; `; -const dataVersionOptions = [ - { - value: "1", - title: "Data version 1", - description: - "Enables downstream processing of older questionnaires without complex features", - }, - { - value: "3", - title: "Data version 3", - description: - "Enables downstream processing of newer questionnaires with complex features", - }, -]; - const DataVersionOption = ({ questionnaireId, value, @@ -112,7 +99,7 @@ const DataVersionSelect = ({ and data version 3. - {dataVersionOptions.map(({ value, title, description }) => ( + {DATA_VERSION_OPTIONS.map(({ value, title, description }) => (