Skip to content

Commit 5dc2c33

Browse files
Merge pull request #4971 from open-formulieren/feature/4650-set-submission-email-address-using-url-parameters
Dynamic email registration recipients using variables
2 parents 5e67644 + b8d142b commit 5dc2c33

24 files changed

+905
-213
lines changed

pyright.pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ include = [
3636
"src/openforms/emails/templatetags/cosign_information.py",
3737
# Registrations
3838
"src/openforms/registrations/tasks.py",
39-
"src/openforms/registrations/contrib/email/config.py",
40-
"src/openforms/registrations/contrib/email/plugin.py",
39+
"src/openforms/registrations/contrib/email/",
4140
"src/openforms/registrations/contrib/stuf_zds/options.py",
4241
"src/openforms/registrations/contrib/stuf_zds/plugin.py",
4342
"src/openforms/registrations/contrib/stuf_zds/typing.py",

src/openforms/js/compiled-lang/en.json

+42
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,12 @@
12731273
"value": "Minimum value"
12741274
}
12751275
],
1276+
"BHr/3M": [
1277+
{
1278+
"type": 0,
1279+
"value": "If specified, the recipient email addresses will be taken from the selected variable. You must still specify 'regular' email addresses as a fallback, in case something is wrong with the variable."
1280+
}
1281+
],
12761282
"BKTOtD": [
12771283
{
12781284
"offset": 0,
@@ -1873,6 +1879,12 @@
18731879
"value": "The co-sign component requires at least one authentication plugin to be enabled."
18741880
}
18751881
],
1882+
"FNT8nq": [
1883+
{
1884+
"type": 0,
1885+
"value": "Variable containing email addresses"
1886+
}
1887+
],
18761888
"FOlQaP": [
18771889
{
18781890
"type": 0,
@@ -2233,6 +2245,12 @@
22332245
"value": " is unknown. We can only display the JSON definition."
22342246
}
22352247
],
2248+
"Igt0Rc": [
2249+
{
2250+
"type": 0,
2251+
"value": "Skip ownership check"
2252+
}
2253+
],
22362254
"IhIqdj": [
22372255
{
22382256
"type": 0,
@@ -3251,6 +3269,12 @@
32513269
"value": "Open editor"
32523270
}
32533271
],
3272+
"T2TGaF": [
3273+
{
3274+
"type": 0,
3275+
"value": "Ownership checks"
3276+
}
3277+
],
32543278
"T2dCIS": [
32553279
{
32563280
"type": 0,
@@ -5571,6 +5595,12 @@
55715595
"value": "The registration result will be an object from the selected type."
55725596
}
55735597
],
5598+
"nhBYT3": [
5599+
{
5600+
"type": 0,
5601+
"value": "Recipients"
5602+
}
5603+
],
55745604
"nkr7r0": [
55755605
{
55765606
"type": 0,
@@ -5889,6 +5919,12 @@
58895919
"value": "How errored submissions of this form will be removed after the limit. Leave blank to use value in General Configuration."
58905920
}
58915921
],
5922+
"qdV9zh": [
5923+
{
5924+
"type": 0,
5925+
"value": "If enabled, then no access control on the referenced object is performed. Ensure that it does not contain private data before checking this!"
5926+
}
5927+
],
58925928
"qmBAmr": [
58935929
{
58945930
"type": 0,
@@ -6297,6 +6333,12 @@
62976333
"value": "Value"
62986334
}
62996335
],
6336+
"vaO0I+": [
6337+
{
6338+
"type": 0,
6339+
"value": "Content"
6340+
}
6341+
],
63006342
"ve3rsH": [
63016343
{
63026344
"type": 0,

src/openforms/js/compiled-lang/nl.json

+43-1
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,12 @@
12771277
"value": "Minimale waarde"
12781278
}
12791279
],
1280+
"BHr/3M": [
1281+
{
1282+
"type": 0,
1283+
"value": "Als een variable geselecteerd is, dan wordt de waarde gebruikt als e-mailadres(sen) van de ontvangers. Je moet nog steeds een vast adres opgeven als terugvaloptie voor het geval er iets fout gaat met de variabele."
1284+
}
1285+
],
12801286
"BKTOtD": [
12811287
{
12821288
"offset": 0,
@@ -1894,6 +1900,12 @@
18941900
"value": "Er moet minstens één authenticatiemethode ingeschakeld zijn voor de mede-ondertekencomponent."
18951901
}
18961902
],
1903+
"FNT8nq": [
1904+
{
1905+
"type": 0,
1906+
"value": "Variabele die adres(sen) bevat"
1907+
}
1908+
],
18971909
"FOlQaP": [
18981910
{
18991911
"type": 0,
@@ -2254,6 +2266,12 @@
22542266
"value": " is niet bekend. We kunnen enkel de JSON-definitie weergeven."
22552267
}
22562268
],
2269+
"Igt0Rc": [
2270+
{
2271+
"type": 0,
2272+
"value": "Sla eigenaarcontrole over"
2273+
}
2274+
],
22572275
"IhIqdj": [
22582276
{
22592277
"type": 0,
@@ -2597,7 +2615,7 @@
25972615
"LeVpdf": [
25982616
{
25992617
"type": 0,
2600-
"value": "Plugin-insellingen: e-mail"
2618+
"value": "Plugin-instellingen: e-mail"
26012619
}
26022620
],
26032621
"LiXrER": [
@@ -3264,6 +3282,12 @@
32643282
"value": "Editor openen"
32653283
}
32663284
],
3285+
"T2TGaF": [
3286+
{
3287+
"type": 0,
3288+
"value": "Eigenaarcontroles"
3289+
}
3290+
],
32673291
"T2dCIS": [
32683292
{
32693293
"type": 0,
@@ -5589,6 +5613,12 @@
55895613
"value": "Het registratieresultaat zal een object van dit type zijn."
55905614
}
55915615
],
5616+
"nhBYT3": [
5617+
{
5618+
"type": 0,
5619+
"value": "Ontvangers"
5620+
}
5621+
],
55925622
"nkr7r0": [
55935623
{
55945624
"type": 0,
@@ -5907,6 +5937,12 @@
59075937
"value": "Geeft aan hoe niet voltooide inzendingen (door fouten in de afhandeling) worden opgeschoond na de bewaartermijn. Laat leeg om de waarde van de algemene configuratie te gebruiken."
59085938
}
59095939
],
5940+
"qdV9zh": [
5941+
{
5942+
"type": 0,
5943+
"value": "Indien aangevinkt, dan worden geen controles uitgevoerd of de (ingelogde) gebruiker toegang heeft op het gerefereerde object. Valideer dat de objecten geen privacy-gevoelige gegevens bevatten voor je dit aanvinkt!"
5944+
}
5945+
],
59105946
"qmBAmr": [
59115947
{
59125948
"type": 0,
@@ -6315,6 +6351,12 @@
63156351
"value": "(Standaard)tekst"
63166352
}
63176353
],
6354+
"vaO0I+": [
6355+
{
6356+
"type": 0,
6357+
"value": "E-mailinhoud"
6358+
}
6359+
],
63186360
"ve3rsH": [
63196361
{
63206362
"type": 0,

src/openforms/js/components/admin/form_design/RegistrationFields.stories.js

+67
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,73 @@ export default {
403403
label: 'textfield2',
404404
},
405405
},
406+
availableFormVariables: [
407+
{
408+
dataFormat: '',
409+
dataType: 'string',
410+
form: 'http://localhost:8000/api/v2/forms/ae26e20c-f059-4fdf-bb82-afc377869bb5',
411+
formDefinition: null,
412+
initialValue: '',
413+
isSensitiveData: false,
414+
key: 'textField1',
415+
name: 'textfield1',
416+
prefillAttribute: '',
417+
prefillPlugin: '',
418+
source: 'component',
419+
},
420+
{
421+
dataFormat: '',
422+
dataType: 'string',
423+
form: 'http://localhost:8000/api/v2/forms/ae26e20c-f059-4fdf-bb82-afc377869bb5',
424+
formDefinition: null,
425+
initialValue: '',
426+
isSensitiveData: false,
427+
key: 'textField2',
428+
name: 'textfield2',
429+
prefillAttribute: '',
430+
prefillPlugin: '',
431+
source: 'component',
432+
},
433+
{
434+
dataFormat: '',
435+
dataType: 'string',
436+
form: 'http://localhost:8000/api/v2/forms/ae26e20c-f059-4fdf-bb82-afc377869bb5',
437+
formDefinition: null,
438+
initialValue: '',
439+
isSensitiveData: false,
440+
key: 'userDefinedVar1',
441+
name: 'User defined string',
442+
prefillAttribute: '',
443+
prefillPlugin: '',
444+
source: 'user_defined',
445+
},
446+
{
447+
dataFormat: '',
448+
dataType: 'array',
449+
form: 'http://localhost:8000/api/v2/forms/ae26e20c-f059-4fdf-bb82-afc377869bb5',
450+
formDefinition: null,
451+
initialValue: [],
452+
isSensitiveData: false,
453+
key: 'userDefinedVar2',
454+
name: 'User defined array',
455+
prefillAttribute: '',
456+
prefillPlugin: '',
457+
source: 'user_defined',
458+
},
459+
{
460+
dataFormat: '',
461+
dataType: 'float',
462+
form: 'http://localhost:8000/api/v2/forms/ae26e20c-f059-4fdf-bb82-afc377869bb5',
463+
formDefinition: null,
464+
initialValue: null,
465+
isSensitiveData: false,
466+
key: 'userDefinedVar3',
467+
name: 'User defined float',
468+
prefillAttribute: '',
469+
prefillPlugin: '',
470+
source: 'user_defined',
471+
},
472+
],
406473
registrationPluginsVariables: [
407474
{
408475
pluginIdentifier: 'stuf-zds-create-zaak',

src/openforms/js/components/admin/form_design/registrations/email/EmailOptionsForm.js

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const EmailOptionsForm = ({name, label, schema, formData, onChange}) => {
2323
/>
2424
}
2525
initialFormData={{
26+
toEmailsFromVariable: '', // ensure an initial value is provided
2627
...formData,
2728
// ensure we have a blank row initially
2829
toEmails: formData.toEmails?.length ? formData.toEmails : [''],
@@ -51,6 +52,7 @@ EmailOptionsForm.propTypes = {
5152
emailSubject: PropTypes.string,
5253
paymentEmails: PropTypes.arrayOf(PropTypes.string),
5354
toEmails: PropTypes.arrayOf(PropTypes.string),
55+
toEmailsFromVariable: PropTypes.string,
5456
}),
5557
onChange: PropTypes.func.isRequired,
5658
};

src/openforms/js/components/admin/form_design/registrations/email/EmailOptionsFormFields.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import EmailHasAttachmentSelect from './fields/EmailHasAttachmentSelect';
1717
import EmailPaymentSubject from './fields/EmailPaymentSubject';
1818
import EmailPaymentUpdateRecipients from './fields/EmailPaymentUpdateRecipients';
1919
import EmailRecipients from './fields/EmailRecipients';
20+
import EmailRecipientsFromVariable from './fields/EmailRecipientsFromVariable';
2021
import EmailSubject from './fields/EmailSubject';
2122

2223
const EmailOptionsFormFields = ({name, schema}) => {
@@ -35,8 +36,26 @@ const EmailOptionsFormFields = ({name, schema}) => {
3536
const relevantErrors = filterErrors(name, validationErrors);
3637
return (
3738
<ValidationErrorsProvider errors={relevantErrors}>
38-
<Fieldset>
39+
<Fieldset
40+
title={
41+
<FormattedMessage
42+
description="Email registration: recipients fieldset title"
43+
defaultMessage="Recipients"
44+
/>
45+
}
46+
>
3947
<EmailRecipients />
48+
<EmailRecipientsFromVariable />
49+
</Fieldset>
50+
51+
<Fieldset
52+
title={
53+
<FormattedMessage
54+
description="Email registration: content fieldset title"
55+
defaultMessage="Content"
56+
/>
57+
}
58+
>
4059
<EmailSubject />
4160
<EmailContentTemplateHTML />
4261
<EmailContentTemplateText />

src/openforms/js/components/admin/form_design/registrations/email/fields/EmailRecipients.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const EmailRecipients = () => {
1919
defaultMessage="The email addresses to which the submission details will be sent"
2020
/>
2121
}
22+
required
2223
>
2324
<ArrayInput
2425
name="toEmails"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {useField} from 'formik';
2+
import React from 'react';
3+
import {FormattedMessage} from 'react-intl';
4+
5+
import Field from 'components/admin/forms/Field';
6+
import FormRow from 'components/admin/forms/FormRow';
7+
import VariableSelection from 'components/admin/forms/VariableSelection';
8+
9+
const EmailRecipientsFromVariable = () => {
10+
const [fieldProps, , {setValue}] = useField('toEmailsFromVariable');
11+
return (
12+
<FormRow>
13+
<Field
14+
name="toEmailsFromVariable"
15+
label={
16+
<FormattedMessage
17+
description="Email registration options 'toEmailsFromVariable' label"
18+
defaultMessage="Variable containing email addresses"
19+
/>
20+
}
21+
helpText={
22+
<FormattedMessage
23+
description="Email registration options 'toEmailsFromVariable' helpText"
24+
defaultMessage={`If specified, the recipient email addresses will be taken
25+
from the selected variable. You must still specify 'regular' email addresses
26+
as a fallback, in case something is wrong with the variable.
27+
`}
28+
/>
29+
}
30+
>
31+
<VariableSelection
32+
{...fieldProps}
33+
isClearable
34+
onChange={event => {
35+
const newValue = event.target.value;
36+
setValue(newValue == null ? '' : newValue);
37+
}}
38+
filter={variable => ['string', 'array'].includes(variable.dataType)}
39+
/>
40+
</Field>
41+
</FormRow>
42+
);
43+
};
44+
45+
EmailRecipientsFromVariable.propTypes = {};
46+
47+
export default EmailRecipientsFromVariable;

src/openforms/js/components/admin/form_design/variables/prefill/PrefillSummary.js

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ const PrefillSummary = ({
9494
}
9595
isOpen={modalOpen}
9696
closeModal={() => setModalOpen(false)}
97+
// FIXME: push this down to the plugin-specific components, somehow
98+
extraModifiers={plugin === 'objects_api' ? ['large'] : undefined}
9799
>
98100
<ErrorBoundary>
99101
<PrefillConfigurationForm

0 commit comments

Comments
 (0)