From 825692d740d6dc29ae01558a5f0a8a6a638d3b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Genevi=C3=A8ve=20Bastien?= Date: Tue, 16 May 2023 12:34:03 -0400 Subject: [PATCH] Update Transition to latest main Let the Survey and ValidateSurvey components load preferences from server when the component is mounted. --- .../src/components/admin/ValidateSurvey.js | 8 ++++++-- packages/evolution-legacy/src/components/survey/Survey.js | 7 ++++++- transition | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/evolution-legacy/src/components/admin/ValidateSurvey.js b/packages/evolution-legacy/src/components/admin/ValidateSurvey.js index 1ca05532..d454bf4b 100644 --- a/packages/evolution-legacy/src/components/admin/ValidateSurvey.js +++ b/packages/evolution-legacy/src/components/admin/ValidateSurvey.js @@ -11,11 +11,11 @@ import moment from 'moment-business-days'; import _get from 'lodash.get'; import config from 'chaire-lib-common/lib/config/shared/project.config'; +import Preferences from 'chaire-lib-common/lib/config/Preferences'; import * as surveyHelperNew from 'evolution-common/lib/utils/helpers'; import Section from '../survey/Section'; import SectionNav from '../survey/SectionNav'; import { withSurveyContext } from 'evolution-frontend/lib/components/hoc/WithSurveyContextHoc'; -import ConfirmModal from '../survey/modal/ConfirmModal'; import LoadingPage from '../shared/LoadingPage'; import { startSetSurveyValidateInterview, startUpdateSurveyValidateInterview, startResetSurveyValidateInterview, startSurveyValidateAddGroupedObjects, startSurveyValidateRemoveGroupedObjects } from '../../actions/survey/survey'; import { InterviewContext } from 'evolution-frontend/lib/contexts/InterviewContext'; @@ -26,7 +26,8 @@ export class ValidateSurvey extends React.Component { constructor(props) { super(props); this.state = { - confirmModalOpenedShortname: null + confirmModalOpenedShortname: null, + preferencesLoaded: false }; // set language if empty and change locale: if (!props.i18n.language || config.languages.indexOf(props.i18n.language) <= -1) @@ -61,6 +62,9 @@ export class ValidateSurvey extends React.Component { componentDidMount() { const interviewUuid = this.props.interviewUuid; this.props.startSetSurveyValidateInterview(interviewUuid); + Preferences.load().then(() => { + this.setState({ preferencesLoaded: true }) + }) } onKeyPress(e) { diff --git a/packages/evolution-legacy/src/components/survey/Survey.js b/packages/evolution-legacy/src/components/survey/Survey.js index 9c57cfc1..6eccf035 100644 --- a/packages/evolution-legacy/src/components/survey/Survey.js +++ b/packages/evolution-legacy/src/components/survey/Survey.js @@ -11,6 +11,7 @@ import moment from 'moment-business-days'; import _get from 'lodash.get'; import config from 'chaire-lib-common/lib/config/shared/project.config'; +import Preferences from 'chaire-lib-common/lib/config/Preferences'; import * as surveyHelperNew from 'evolution-common/lib/utils/helpers'; import Section from './Section'; import SectionNav from './SectionNav'; @@ -28,7 +29,8 @@ export class Survey extends React.Component { super(props); surveyHelperNew.devLog('params_survey', props.location.search) this.state = { - confirmModalOpenedShortname: null + confirmModalOpenedShortname: null, + preferencesLoaded: false }; // set language if empty and change locale: if (!props.i18n.language || config.languages.indexOf(props.i18n.language) <= -1) @@ -67,6 +69,9 @@ export class Survey extends React.Component { const pathSectionParentSection = pathSectionShortname && this.surveyContext.sections[pathSectionShortname] ? this.surveyContext.sections[pathSectionShortname].parentSection : null; const { state } = this.context; this.props.startSetInterview(existingActiveSection || pathSectionParentSection, surveyUuid, state.status === 'entering' && Object.keys(state.responses).length > 0 ? state.responses : undefined); + Preferences.load().then(() => { + this.setState({ preferencesLoaded: true }) + }); } onKeyPress(e) { diff --git a/transition b/transition index cd0582bb..15e96ba1 160000 --- a/transition +++ b/transition @@ -1 +1 @@ -Subproject commit cd0582bb03c64cdec90ef41d23d391736a2bf5fc +Subproject commit 15e96ba10d49e5837d250746c728939efdc943a2