From b89a8700e65eef79c12409f2587ff35d4bc2b3f1 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 4 Sep 2024 18:32:10 +0200 Subject: [PATCH 1/5] :recycle: Re-order/group model fields --- src/openforms/forms/models/form.py | 40 ++++++++++++++++-------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/openforms/forms/models/form.py b/src/openforms/forms/models/form.py index 3234eaf30b..7bf5b184cf 100644 --- a/src/openforms/forms/models/form.py +++ b/src/openforms/forms/models/form.py @@ -165,6 +165,27 @@ class Form(models.Model): ), default=True, ) + ask_privacy_consent = models.CharField( + _("ask privacy consent"), + max_length=50, + choices=StatementCheckboxChoices.choices, + default=StatementCheckboxChoices.global_setting, + help_text=_( + "If enabled, the user will have to agree to the privacy policy before submitting a form." + ), + ) + ask_statement_of_truth = models.CharField( + _("ask statement of truth"), + max_length=50, + choices=StatementCheckboxChoices.choices, + default=StatementCheckboxChoices.global_setting, + help_text=_( + "If enabled, the user will have to agree that they filled out the form " + "truthfully before submitting it." + ), + ) + + # Content displayed to end users begin_text = models.CharField( _("begin text"), max_length=50, @@ -214,25 +235,6 @@ class Form(models.Model): ), ), ) - ask_privacy_consent = models.CharField( - _("ask privacy consent"), - max_length=50, - choices=StatementCheckboxChoices.choices, - default=StatementCheckboxChoices.global_setting, - help_text=_( - "If enabled, the user will have to agree to the privacy policy before submitting a form." - ), - ) - ask_statement_of_truth = models.CharField( - _("ask statement of truth"), - max_length=50, - choices=StatementCheckboxChoices.choices, - default=StatementCheckboxChoices.global_setting, - help_text=_( - "If enabled, the user will have to agree that they filled out the form " - "truthfully before submitting it." - ), - ) # life cycle management active = models.BooleanField(_("active"), default=False) From 5de4987f919ea584efc35f3b103cb87b4357db9d Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 4 Sep 2024 18:36:18 +0200 Subject: [PATCH 2/5] :card_file_box: [#4545] Add model fields for introduction page wysiwyg content --- ...form_introduction_page_content_and_more.py | 61 +++++++++++++++++++ src/openforms/forms/models/form.py | 10 +++ src/openforms/forms/translation.py | 1 + 3 files changed, 72 insertions(+) create mode 100644 src/openforms/forms/migrations/0098_form_introduction_page_content_and_more.py diff --git a/src/openforms/forms/migrations/0098_form_introduction_page_content_and_more.py b/src/openforms/forms/migrations/0098_form_introduction_page_content_and_more.py new file mode 100644 index 0000000000..56d92e5440 --- /dev/null +++ b/src/openforms/forms/migrations/0098_form_introduction_page_content_and_more.py @@ -0,0 +1,61 @@ +# Generated by Django 4.2.15 on 2024-09-04 16:35 + +from django.db import migrations + +import tinymce.models + +import csp_post_processor.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ("forms", "0097_v267_to_v270"), + ] + + operations = [ + migrations.AddField( + model_name="form", + name="introduction_page_content", + field=csp_post_processor.fields.CSPPostProcessedWYSIWYGField( + base_field=tinymce.models.HTMLField( + blank=True, + help_text="Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page.", + verbose_name="introduction page", + ), + blank=True, + help_text="Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page.", + verbose_name="introduction page", + ), + ), + migrations.AddField( + model_name="form", + name="introduction_page_content_en", + field=csp_post_processor.fields.CSPPostProcessedWYSIWYGField( + base_field=tinymce.models.HTMLField( + blank=True, + help_text="Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page.", + verbose_name="introduction page", + ), + blank=True, + help_text="Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page.", + null=True, + verbose_name="introduction page", + ), + ), + migrations.AddField( + model_name="form", + name="introduction_page_content_nl", + field=csp_post_processor.fields.CSPPostProcessedWYSIWYGField( + base_field=tinymce.models.HTMLField( + blank=True, + help_text="Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page.", + verbose_name="introduction page", + ), + blank=True, + help_text="Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page.", + null=True, + verbose_name="introduction page", + ), + ), + ] diff --git a/src/openforms/forms/models/form.py b/src/openforms/forms/models/form.py index 7bf5b184cf..30d4c0e854 100644 --- a/src/openforms/forms/models/form.py +++ b/src/openforms/forms/models/form.py @@ -226,6 +226,16 @@ class Form(models.Model): "Leave blank to get value from global configuration." ), ) + introduction_page_content = CSPPostProcessedWYSIWYGField( + HTMLField( + blank=True, + verbose_name=_("introduction page"), + help_text=_( + "Content for the introduction page that leads to the start page of the " + "form. Leave blank to disable the introduction page." + ), + ), + ) explanation_template = CSPPostProcessedWYSIWYGField( HTMLField( blank=True, diff --git a/src/openforms/forms/translation.py b/src/openforms/forms/translation.py index 231fd71137..9ed81ac3db 100644 --- a/src/openforms/forms/translation.py +++ b/src/openforms/forms/translation.py @@ -13,6 +13,7 @@ class FormTranslationOptions(TranslationOptions): "change_text", "confirm_text", "explanation_template", + "introduction_page_content", ) From 11a774d10c069522e92809470cf3d4013c0faeb4 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 4 Sep 2024 18:39:16 +0200 Subject: [PATCH 3/5] :sparkles: [#4545] Expose Form.introductionPageContent in the API --- src/openapi.yaml | 22 +++++++++++++++++++++ src/openforms/forms/api/serializers/form.py | 2 ++ src/openforms/forms/tests/test_api_forms.py | 2 ++ 3 files changed, 26 insertions(+) diff --git a/src/openapi.yaml b/src/openapi.yaml index f62e7b9bbf..14e40ee9ec 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -7588,6 +7588,11 @@ components: description: The content of the submission confirmation page. It can contain variables that will be templated from the submitted form data. If not specified, the global template will be used. + introductionPageContent: + type: string + title: Introduction page + description: Content for the introduction page that leads to the start page + of the form. Leave blank to disable the introduction page. explanationTemplate: type: string description: Content that will be shown on the start page of the form, below @@ -7999,6 +8004,12 @@ components: the form is filled in correctly. Leave blank to get value from global configuration. maxLength: 50 + introductionPageContent: + type: string + nullable: true + title: Introduction page [en] + description: Content for the introduction page that leads to the start page + of the form. Leave blank to disable the introduction page. explanationTemplate: type: string nullable: true @@ -8164,6 +8175,12 @@ components: the form is filled in correctly. Leave blank to get value from global configuration. maxLength: 50 + introductionPageContent: + type: string + nullable: true + title: Introduction page [nl] + description: Content for the introduction page that leads to the start page + of the form. Leave blank to disable the introduction page. explanationTemplate: type: string nullable: true @@ -9226,6 +9243,11 @@ components: description: The content of the submission confirmation page. It can contain variables that will be templated from the submitted form data. If not specified, the global template will be used. + introductionPageContent: + type: string + title: Introduction page + description: Content for the introduction page that leads to the start page + of the form. Leave blank to disable the introduction page. explanationTemplate: type: string description: Content that will be shown on the start page of the form, below diff --git a/src/openforms/forms/api/serializers/form.py b/src/openforms/forms/api/serializers/form.py index 9f354fe2a1..1f17dd00ac 100644 --- a/src/openforms/forms/api/serializers/form.py +++ b/src/openforms/forms/api/serializers/form.py @@ -272,6 +272,7 @@ class Meta: "deactivate_on", "is_deleted", "submission_confirmation_template", + "introduction_page_content", "explanation_template", "submission_allowed", "suspension_allowed", @@ -296,6 +297,7 @@ class Meta: public_fields = ( "uuid", "name", + "introduction_page_content", "explanation_template", "login_required", "authentication_backends", diff --git a/src/openforms/forms/tests/test_api_forms.py b/src/openforms/forms/tests/test_api_forms.py index 2967ebb494..c565f7b03e 100644 --- a/src/openforms/forms/tests/test_api_forms.py +++ b/src/openforms/forms/tests/test_api_forms.py @@ -1441,6 +1441,7 @@ def test_detail_staff_show_translations(self): "begin_text": "start", "change_text": "change", "confirm_text": "confirm", + "introduction_page_content": "", "explanation_template": "", "name": "Form 1", "previous_text": "prev", @@ -1450,6 +1451,7 @@ def test_detail_staff_show_translations(self): "begin_text": "", "change_text": "", "confirm_text": "", + "introduction_page_content": "", "explanation_template": "", "name": "", "previous_text": "", From 103e511979080910fb98cc9d6e97500faac45f91 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 4 Sep 2024 18:45:07 +0200 Subject: [PATCH 4/5] :sparkles: [#4545] Add WYSIWYG fields to form create/edit admin --- src/openforms/conf/tinymce_config.json | 5 +- .../admin/form_design/FormDetailFields.js | 87 +++++++++++++------ .../form_design/MissingTranslationsWarning.js | 4 +- .../admin/form_design/form-creation-form.js | 1 + .../admin/form_design/translations.js | 1 + 5 files changed, 67 insertions(+), 31 deletions(-) diff --git a/src/openforms/conf/tinymce_config.json b/src/openforms/conf/tinymce_config.json index b41b1ed52c..659bbb4aab 100644 --- a/src/openforms/conf/tinymce_config.json +++ b/src/openforms/conf/tinymce_config.json @@ -21,10 +21,11 @@ "help", "wordcount" ], - "toolbar": "undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | table bullist numlist outdent indent | link unlink removeformat | help", + "toolbar": "undo redo | blocks | bold italic backcolor | alignleft aligncenter alignright alignjustify | table bullist numlist outdent indent | link unlink removeformat | help", "content_style": "body { font-family:Helvetica,Arial,sans-serif; font-size:14px }", "default_link_target": "_blank", "link_default_protocol": "https", "link_assume_external_targets": false, - "convert_urls": false + "convert_urls": false, + "block_formats": "Paragraph=p; Heading 2=h2; Heading 3=h3; Heading 4=h4; Heading 5=h5; Heading 6=h6" } diff --git a/src/openforms/js/components/admin/form_design/FormDetailFields.js b/src/openforms/js/components/admin/form_design/FormDetailFields.js index cbe5105fd7..6c36b05452 100644 --- a/src/openforms/js/components/admin/form_design/FormDetailFields.js +++ b/src/openforms/js/components/admin/form_design/FormDetailFields.js @@ -63,35 +63,68 @@ const FormDetailFields = ({form: {slug, translations, appointmentOptions}, onCha {!isAppointment && ( - - - } - helpText={ - + + + } + helpText={ + + } + > + + onChange({ + target: { + name: `form.translations.${langCode}.introductionPageContent`, + value: newValue, + }, + }) + } /> - } - > - - onChange({ - target: { - name: `form.translations.${langCode}.explanationTemplate`, - value: newValue, - }, - }) + + + + + } - /> - - + helpText={ + + } + > + + onChange({ + target: { + name: `form.translations.${langCode}.explanationTemplate`, + value: newValue, + }, + }) + } + /> + + + )} )} diff --git a/src/openforms/js/components/admin/form_design/MissingTranslationsWarning.js b/src/openforms/js/components/admin/form_design/MissingTranslationsWarning.js index 2a56eefc19..b01129e59e 100644 --- a/src/openforms/js/components/admin/form_design/MissingTranslationsWarning.js +++ b/src/openforms/js/components/admin/form_design/MissingTranslationsWarning.js @@ -98,9 +98,9 @@ const MissingTranslationsWarning = ({form, formSteps}) => { extractMissingTranslations( form.translations, , - ['name', 'explanationTemplate'], + ['name', 'introductionPageContent', 'explanationTemplate'], undefined, - ['explanationTemplate'] + ['introductionPageContent', 'explanationTemplate'] ), extractMissingTranslations( form.translations, diff --git a/src/openforms/js/components/admin/form_design/form-creation-form.js b/src/openforms/js/components/admin/form_design/form-creation-form.js index 88438bdb85..d9310aad5a 100644 --- a/src/openforms/js/components/admin/form_design/form-creation-form.js +++ b/src/openforms/js/components/admin/form_design/form-creation-form.js @@ -183,6 +183,7 @@ const FORM_FIELDS_TO_TAB_NAMES = { const TRANSLATION_FIELD_TO_TAB_NAMES = { name: 'form', + introductionPageContent: 'form', explanationTemplate: 'form', submissionConfirmationTemplate: 'submission-confirmation', beginText: 'literals', diff --git a/src/openforms/js/components/admin/form_design/translations.js b/src/openforms/js/components/admin/form_design/translations.js index 946bd1e2f4..1d07ed456f 100644 --- a/src/openforms/js/components/admin/form_design/translations.js +++ b/src/openforms/js/components/admin/form_design/translations.js @@ -10,6 +10,7 @@ export const initialFormTranslations = { previousText: '', beginText: '', submissionConfirmationTemplate: '', + introductionPageContent: '', explanationTemplate: '', }; From b25d0c1a3ecf6789486ef59c872f917e94a9820c Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 4 Sep 2024 18:53:42 +0200 Subject: [PATCH 5/5] :globe_with_meridians: [#4545] Extract translatable messages --- src/openforms/js/compiled-lang/en.json | 12 ++++++++++++ src/openforms/js/compiled-lang/nl.json | 12 ++++++++++++ src/openforms/js/lang/en.json | 10 ++++++++++ src/openforms/js/lang/nl.json | 10 ++++++++++ 4 files changed, 44 insertions(+) diff --git a/src/openforms/js/compiled-lang/en.json b/src/openforms/js/compiled-lang/en.json index 32b7cf654a..075a3830ba 100644 --- a/src/openforms/js/compiled-lang/en.json +++ b/src/openforms/js/compiled-lang/en.json @@ -3519,6 +3519,12 @@ "value": "Are you sure you want to delete this?" } ], + "Z5lydZ": [ + { + "type": 0, + "value": "Introduction page" + } + ], "ZB6mnn": [ { "type": 0, @@ -4147,6 +4153,12 @@ "value": "configured" } ], + "dyBb9g": [ + { + "type": 0, + "value": "Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page." + } + ], "e6SsfR": [ { "type": 0, diff --git a/src/openforms/js/compiled-lang/nl.json b/src/openforms/js/compiled-lang/nl.json index 6e81a9add1..5d1bef19bc 100644 --- a/src/openforms/js/compiled-lang/nl.json +++ b/src/openforms/js/compiled-lang/nl.json @@ -3536,6 +3536,12 @@ "value": "Weet u zeker dat u dit wilt verwijderen?" } ], + "Z5lydZ": [ + { + "type": 0, + "value": "Introduction page" + } + ], "ZB6mnn": [ { "type": 0, @@ -4169,6 +4175,12 @@ "value": "configured" } ], + "dyBb9g": [ + { + "type": 0, + "value": "Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page." + } + ], "e6SsfR": [ { "type": 0, diff --git a/src/openforms/js/lang/en.json b/src/openforms/js/lang/en.json index 8fe29dbebf..d13e0d76d1 100644 --- a/src/openforms/js/lang/en.json +++ b/src/openforms/js/lang/en.json @@ -1589,6 +1589,11 @@ "description": "Default delete confirmation message", "originalDefault": "Are you sure you want to delete this?" }, + "Z5lydZ": { + "defaultMessage": "Introduction page", + "description": "form.introductionPageContent label", + "originalDefault": "Introduction page" + }, "ZB6mnn": { "defaultMessage": "The variable key must be unique within a form", "description": "Unique key error message", @@ -1839,6 +1844,11 @@ "description": "data type date", "originalDefault": "Date" }, + "dyBb9g": { + "defaultMessage": "Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page.", + "description": "form.introductionPageContent help text", + "originalDefault": "Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page." + }, "eBk+W0": { "defaultMessage": "Manage process variables", "description": "Camunda process var selection modal title", diff --git a/src/openforms/js/lang/nl.json b/src/openforms/js/lang/nl.json index 4a7ef49ae1..c73c4afe5e 100644 --- a/src/openforms/js/lang/nl.json +++ b/src/openforms/js/lang/nl.json @@ -1604,6 +1604,11 @@ "description": "Default delete confirmation message", "originalDefault": "Are you sure you want to delete this?" }, + "Z5lydZ": { + "defaultMessage": "Introduction page", + "description": "form.introductionPageContent label", + "originalDefault": "Introduction page" + }, "ZB6mnn": { "defaultMessage": "De sleutel van een variabele moet uniek zijn binnen een formulier", "description": "Unique key error message", @@ -1857,6 +1862,11 @@ "description": "data type date", "originalDefault": "Date" }, + "dyBb9g": { + "defaultMessage": "Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page.", + "description": "form.introductionPageContent help text", + "originalDefault": "Content for the introduction page that leads to the start page of the form. Leave blank to disable the introduction page." + }, "eBk+W0": { "defaultMessage": "Beheer procesvariabelen", "description": "Camunda process var selection modal title",