From 4cec444b6d76fd1cefae2e549b3414ff29cde3b7 Mon Sep 17 00:00:00 2001 From: Bjarke Madsen <bjarke@nordu.net> Date: Tue, 1 Aug 2023 17:56:32 +0200 Subject: [PATCH] Don't show buttons on readonly surveys --- survey-frontend/src/SurveyContainerComponent.tsx | 4 ++-- survey-frontend/src/SurveyNavigationComponent.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/survey-frontend/src/SurveyContainerComponent.tsx b/survey-frontend/src/SurveyContainerComponent.tsx index c77e9f83..c419e971 100644 --- a/survey-frontend/src/SurveyContainerComponent.tsx +++ b/survey-frontend/src/SurveyContainerComponent.tsx @@ -22,7 +22,7 @@ function SurveyContainerComponent({ loadFrom, saveTo = '', readonly = false }) { }, []); if (surveyModel === undefined) { - return 'loading...' + return 'loading survey...' } async function getModel() { @@ -128,7 +128,7 @@ function SurveyContainerComponent({ loadFrom, saveTo = '', readonly = false }) { </Row> <Row> - <SurveyNavigationComponent surveyModel={surveyModel} endSurvey={endSurvey} saveSurvey={saveSurvey} validatePage={validatePage}> + <SurveyNavigationComponent surveyModel={surveyModel} endSurvey={endSurvey} saveSurvey={saveSurvey} validatePage={validatePage} readonly={readonly}> <SurveyComponent surveyModel={surveyModel} verificationStatus={verificationStatus} /> </SurveyNavigationComponent> </Row> diff --git a/survey-frontend/src/SurveyNavigationComponent.tsx b/survey-frontend/src/SurveyNavigationComponent.tsx index 1bb5ec82..3a7acc58 100644 --- a/survey-frontend/src/SurveyNavigationComponent.tsx +++ b/survey-frontend/src/SurveyNavigationComponent.tsx @@ -3,9 +3,8 @@ import ProgressBar from './ProgressBar'; import { Container, Row } from "react-bootstrap"; -function SurveyNavigationComponent({ surveyModel, endSurvey, saveSurvey, validatePage, children }) { +function SurveyNavigationComponent({ surveyModel, endSurvey, saveSurvey, validatePage, children, readonly }) { const [pageNo, setPageNo] = useState(0); - useEffect(() => { setPageNo(surveyModel.currentPageNo) }, [surveyModel]); @@ -27,6 +26,9 @@ function SurveyNavigationComponent({ surveyModel, endSurvey, saveSurvey, validat }; const renderExternalNavigation = () => { + if (readonly) { + return <></>; + } return ( <div className="navigation-block"> <div className="navigation-progress-container"> -- GitLab