Skip to content

Commit

Permalink
Merge pull request #618 from InseeFr/dev-warning-varcal
Browse files Browse the repository at this point in the history
Dev warning varcal
  • Loading branch information
BulotF authored Sep 8, 2022
2 parents 5222893 + 943b6e9 commit 4d7ad23
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 15 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pogues",
"version": "1.3.1",
"version": "1.3.2",
"description": "Outil de conception et de test de questionnaires.",
"repository": {
"type": "git",
Expand All @@ -17,12 +17,12 @@
"email": "[email protected]"
},
{
"name": "Loic Henninger",
"email": "loic.henninger@insee.fr"
"name": "François Bulot",
"email": "francois.bulot@insee.fr"
},
{
"name": "Ophelie Rogel",
"email": "ophelie.rogel@insee.fr"
"name": "Ophelie Bibonne",
"email": "ophelie.bibonne@insee.fr"
},
{
"name": "Nicolas Laval",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { ErrorsIntegrity as ErrorsIntegrityPanel } from 'layout/errors-integrity

import Dictionary from 'utils/dictionary/dictionary';
import { getSortedChildren } from 'utils/component/component-utils';
import { ERRORS_INTEGRITY } from 'constants/dom-constants';

const { INNER, ALERT, LIST } = ERRORS_INTEGRITY;

const { LOOP, FILTER, NESTEDFILTRE } = COMPONENT_TYPE;

Expand All @@ -25,6 +28,8 @@ const QuestionnaireListComponents = props => {
editingComponentId,
errorsIntegrity,
setSelectedComponentId,
activeCalculatedVariables,
calculatedVariables,
} = props;

useEffect(() => {
Expand All @@ -35,6 +40,17 @@ const QuestionnaireListComponents = props => {
const [showComponentModal, setShowComponentModal] = useState(false);
const [showRemoveQuestionnaireDialog, setShowRemoveQuestionnaireDialog] =
useState(false);
const [showWarning, setShowWarning] = useState(false);

// Temporary : to help diagnose calculated variables bug
useEffect(() => {
if (questionnaire.id && calculatedVariables[questionnaire.id]) {
setShowWarning(
Object.keys(activeCalculatedVariables).length === 0 &&
Object.keys(calculatedVariables[questionnaire.id]).length !== 0,
);
}
}, [activeCalculatedVariables, calculatedVariables, questionnaire]);

const handleOpenQuestionnaireDetail = () => {
setShowQuestionnaireModal(true);
Expand Down Expand Up @@ -161,7 +177,40 @@ const QuestionnaireListComponents = props => {
</div>
</div>

{/* Questionnaire integrity errors */}
{/* Temporary warning to help diagnose the bug concerning disappearing of calculated variables */}
{showWarning && (
<div id="errors-integrity">
<div className={INNER}>
<div className={ALERT} style={{ marginTop: '2.5em' }}>
<div className="alert-icon big">
<div className="alert-triangle" />!
</div>
</div>
<div className={LIST}>
<ul>
<li>
Il n'y a plus de variables calculées dans votre
questionnaire.{' '}
<strong>
Si ce n'est pas une action voulue de votre part
</strong>
, il s'agit probablement d'une erreur de l'application.
Dans ce cas, veuillez contacter au plus vite{' '}
<a href="mailto:[email protected];[email protected];[email protected];[email protected]">
l'équipe de l'atelier de conception
</a>{' '}
pour que nous corrigions ce problème.
</li>
<li>
Par ailleurs, si vous quittez votre questionnaire
maintenant sans le sauvegarder, vous retrouverez les
variables calculées en retournant sur le questionnaire.
</li>
</ul>
</div>
</div>
</div>
)}

<ErrorsIntegrityPanel
errorsIntegrity={errorsIntegrity}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const mapStateToProps = state => ({
selectedComponentId: state.appState.selectedComponentId,
editingComponentId: state.appState.editingComponentId,
errorsIntegrity: state.errors.errorsIntegrity,
activeCalculatedVariables: state.appState.activeCalculatedVariablesById,
calculatedVariables: state.calculatedVariableByQuestionnaire,
});

const mapDispatchToProps = {
Expand Down
20 changes: 11 additions & 9 deletions src/layout/questionnaire-nav/components/questionnaire-nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ const propTypes = {
};

// Component
function QuestionnaireNav({
questionnaire,
componentsStore,
setSelectedComponentId,
setEditingComponentId,
editingComponentId,
removeComponent,
}) {
const QuestionnaireNav = props => {
const {
questionnaire,
componentsStore,
setSelectedComponentId,
setEditingComponentId,
editingComponentId,
removeComponent,
} = props;

return (
<div className={COMPONENT_CLASS}>
<div className="nav-style">
Expand Down Expand Up @@ -57,7 +59,7 @@ function QuestionnaireNav({
</div>
</div>
);
}
};

QuestionnaireNav.propTypes = propTypes;

Expand Down

0 comments on commit 4d7ad23

Please sign in to comment.