From 3660f8ce34948f5023be40164fa875de19562ee9 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Thu, 1 Aug 2024 13:10:25 +0200 Subject: [PATCH 1/8] Refactor Template to Html component and add page/questionset/question help templates --- rdmo/core/assets/js/components/Html.js | 20 +++++++++++++++++++ rdmo/core/assets/js/components/Template.js | 15 -------------- rdmo/core/settings.py | 3 +++ .../js/interview/components/main/Done.js | 4 ++-- .../js/interview/components/main/Errors.js | 4 ++-- .../js/interview/components/main/page/Page.js | 7 ++++--- .../components/main/page/PageHead.js | 9 +++++---- .../components/main/page/PageHelp.js | 15 -------------- .../components/main/question/Question.js | 2 ++ .../main/question/QuestionAddValueHelp.js | 4 ++-- .../components/main/question/QuestionHelp.js | 7 +++---- .../main/question/QuestionHelpTemplate.js | 14 +++++++++++++ .../main/question/QuestionWarning.js | 4 ++-- .../main/questionset/QuestionSet.js | 6 +++++- .../main/questionset/QuestionSetAddSetHelp.js | 4 ++-- .../main/questionset/QuestionSetHelp.js | 4 +++- .../questionset/QuestionSetHelpTemplate.js | 14 +++++++++++++ .../main/widget/common/OptionHelp.js | 4 +++- .../main/widget/common/OptionText.js | 4 +++- .../interview/components/sidebar/Buttons.js | 4 ++-- .../components/sidebar/Navigation.js | 4 ++-- .../interview/components/sidebar/Overview.js | 4 ++-- .../interview/components/sidebar/Progress.js | 4 ++-- rdmo/projects/assets/scss/interview.scss | 10 ++++++++++ .../projects/project_interview_page_help.html | 0 .../project_interview_question_help.html | 0 .../project_interview_questionset_help.html | 0 27 files changed, 107 insertions(+), 63 deletions(-) create mode 100644 rdmo/core/assets/js/components/Html.js delete mode 100644 rdmo/core/assets/js/components/Template.js delete mode 100644 rdmo/projects/assets/js/interview/components/main/page/PageHelp.js create mode 100644 rdmo/projects/assets/js/interview/components/main/question/QuestionHelpTemplate.js create mode 100644 rdmo/projects/assets/js/interview/components/main/questionset/QuestionSetHelpTemplate.js create mode 100644 rdmo/projects/templates/projects/project_interview_page_help.html create mode 100644 rdmo/projects/templates/projects/project_interview_question_help.html create mode 100644 rdmo/projects/templates/projects/project_interview_questionset_help.html diff --git a/rdmo/core/assets/js/components/Html.js b/rdmo/core/assets/js/components/Html.js new file mode 100644 index 0000000000..d0f18d4fe0 --- /dev/null +++ b/rdmo/core/assets/js/components/Html.js @@ -0,0 +1,20 @@ +import React from 'react' +import PropTypes from 'prop-types' +import { isEmpty } from 'lodash' + +const Html = ({ html }) => { + return !isEmpty(html) && ( +
+ ) +} + +Html.defaultProps = { + className: '' +} + +Html.propTypes = { + className: PropTypes.string, + html: PropTypes.string +} + +export default Html diff --git a/rdmo/core/assets/js/components/Template.js b/rdmo/core/assets/js/components/Template.js deleted file mode 100644 index 75aaaf90d6..0000000000 --- a/rdmo/core/assets/js/components/Template.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' - -const Template = ({ template }) => { - - return ( -
- ) -} - -Template.propTypes = { - template: PropTypes.string.isRequired -} - -export default Template diff --git a/rdmo/core/settings.py b/rdmo/core/settings.py index 1ff40524cb..9b1c482ad0 100644 --- a/rdmo/core/settings.py +++ b/rdmo/core/settings.py @@ -225,8 +225,11 @@ 'projects/project_interview_multiple_values_warning.html', 'projects/project_interview_navigation_help.html', 'projects/project_interview_overview_help.html', + 'projects/project_interview_page_help.html', 'projects/project_interview_page_tabs_help.html', 'projects/project_interview_progress_help.html', + 'projects/project_interview_question_help.html', + 'projects/project_interview_questionset_help.html', ] EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/rdmo/projects/assets/js/interview/components/main/Done.js b/rdmo/projects/assets/js/interview/components/main/Done.js index 3bd277e28c..7ffe6095bb 100644 --- a/rdmo/projects/assets/js/interview/components/main/Done.js +++ b/rdmo/projects/assets/js/interview/components/main/Done.js @@ -5,7 +5,7 @@ import baseUrl from 'rdmo/core/assets/js/utils/baseUrl' import projectId from '../../utils/projectId' -import Template from 'rdmo/core/assets/js/components/Template' +import Html from 'rdmo/core/assets/js/components/Html' const Done = ({ templates }) => { @@ -14,7 +14,7 @@ const Done = ({ templates }) => { return ( <> -