Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for email fields to override default sender #71

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ msgstr "Senden Sie eine E-Mail-Kopie an diese Adresse"
msgid "form_useAsBCC_description"
msgstr "Wenn ausgewählt, wird auch eine Kopie der E-Mail an diese Adresse gesendet."

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr "Als Absender setzen"

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -477,3 +482,8 @@ msgstr "Ergebnis"
# defaultMessage: Title
msgid "title"
msgstr "Titel"

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr "Standard Absender wird dann mit dieser Adresse überschrieben."
10 changes: 10 additions & 0 deletions locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ msgstr ""
msgid "form_useAsBCC_description"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -477,3 +482,8 @@ msgstr ""
# defaultMessage: Title
msgid "title"
msgstr "Title"

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
10 changes: 10 additions & 0 deletions locales/es/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ msgstr "Enviar una copia del e-mail a esta dirección"
msgid "form_useAsBCC_description"
msgstr "Si está seleccionado, una copia del mensaje se enviará a esta dirección"

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -486,3 +491,8 @@ msgstr "Resultado"
# defaultMessage: Title
msgid "title"
msgstr "Título"

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
10 changes: 10 additions & 0 deletions locales/eu/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ msgstr "Bidali kopia bat eposta honetara"
msgid "form_useAsBCC_description"
msgstr "Aukeratzen bada, emailaren kopia bat bidaliko da helbide honetara."

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -479,3 +484,8 @@ msgstr "emaitza"
# defaultMessage: Title
msgid "title"
msgstr "Izenburua"

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
10 changes: 10 additions & 0 deletions locales/fr/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ msgstr ""
msgid "form_useAsBCC_description"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -477,3 +482,8 @@ msgstr ""
# defaultMessage: Title
msgid "title"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
10 changes: 10 additions & 0 deletions locales/it/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ msgstr "Invia una copia dell'email a questo indirizzo"
msgid "form_useAsBCC_description"
msgstr "Se selezionato, una copia dell'email verrà inviata anche a questo indirizzo."

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -477,3 +482,8 @@ msgstr "risultato"
# defaultMessage: Title
msgid "title"
msgstr "Titolo"

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
10 changes: 10 additions & 0 deletions locales/ja/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ msgstr ""
msgid "form_useAsBCC_description"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -477,3 +482,8 @@ msgstr ""
# defaultMessage: Title
msgid "title"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
10 changes: 10 additions & 0 deletions locales/nl/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ msgstr ""
msgid "form_useAsBCC_description"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -477,3 +482,8 @@ msgstr ""
# defaultMessage: Title
msgid "title"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
10 changes: 10 additions & 0 deletions locales/pt/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ msgstr ""
msgid "form_useAsBCC_description"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -477,3 +482,8 @@ msgstr ""
# defaultMessage: Title
msgid "title"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
10 changes: 10 additions & 0 deletions locales/pt_BR/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ msgstr ""
msgid "form_useAsBCC_description"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -483,3 +488,8 @@ msgstr ""
# defaultMessage: Title
msgid "title"
msgstr "título"

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
10 changes: 10 additions & 0 deletions locales/ro/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ msgstr ""
msgid "form_useAsBCC_description"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -477,3 +482,8 @@ msgstr ""
# defaultMessage: Title
msgid "title"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
12 changes: 11 additions & 1 deletion locales/volto.pot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Plone\n"
"POT-Creation-Date: 2023-05-29T11:05:12.094Z\n"
"POT-Creation-Date: 2023-09-12T08:29:55.978Z\n"
"Last-Translator: Plone i18n <[email protected]>\n"
"Language-Team: Plone i18n <[email protected]>\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -445,6 +445,11 @@ msgstr ""
msgid "form_useAsBCC_description"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'from'
msgid "form_useAsFrom"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: Use as 'reply to'
msgid "form_useAsReplyTo"
Expand Down Expand Up @@ -479,3 +484,8 @@ msgstr ""
# defaultMessage: Title
msgid "title"
msgstr ""

#: components/FieldTypeSchemaExtenders/FromSchemaExtender
# defaultMessage: If selected, this will override the default sender.
msgid "useAsFrom_description"
msgstr ""
3 changes: 2 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const SUBMIT_FORM_ACTION = 'SUBMIT_FORM_ACTION';
* @param {Object} data
* @returns {Object} attachments
*/
export function submitForm(path = '', block_id, data, attachments, captcha) {
export function submitForm(path = '', block_id, data, attachments, captcha, from) {
return {
type: SUBMIT_FORM_ACTION,
request: {
Expand All @@ -24,6 +24,7 @@ export function submitForm(path = '', block_id, data, attachments, captcha) {
data,
attachments,
captcha,
from,
},
},
};
Expand Down
16 changes: 15 additions & 1 deletion src/components/FieldTypeSchemaExtenders/FromSchemaExtender.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ const messages = defineMessages({
id: 'form_field_input_values',
defaultMessage: 'Possible values',
},
useAsFrom: {
id: 'form_useAsFrom',
defaultMessage: "Use as 'from'",
},
useAsFrom_description: {
id: 'useAsFrom_description',
defaultMessage: 'If selected, this will override the default sender.',
},
useAsReplyTo: {
id: 'form_useAsReplyTo',
defaultMessage: "Use as 'reply to'",
Expand All @@ -26,8 +34,14 @@ const messages = defineMessages({

export const FromSchemaExtender = (intl) => {
return {
fields: ['use_as_reply_to', 'use_as_bcc'],
fields: ['use_as_from', 'use_as_reply_to', 'use_as_bcc'],
properties: {
use_as_from: {
title: intl.formatMessage(messages.useAsFrom),
description: intl.formatMessage(messages.useAsFrom_description),
type: 'boolean',
default: false,
},
use_as_reply_to: {
title: intl.formatMessage(messages.useAsReplyTo),
description: intl.formatMessage(messages.useAsReplyTo_description),
Expand Down
15 changes: 15 additions & 0 deletions src/components/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ const View = ({ data, id, path }) => {
}
}
});

// if there is an email field which should be used as sender,
// we want to set from value regarding this field
let from = null;
const fromField = data.subblocks.find(
(b) => ['email', 'from'].includes(b.field_type) && b.use_as_from,
);
if (fromField) {
const fromFieldId = `email_${fromField.field_id}`;
if (formData.hasOwnProperty(fromFieldId)) {
from = formData[fromFieldId].value;
}
}

dispatch(
submitForm(
path,
Expand All @@ -197,6 +211,7 @@ const View = ({ data, id, path }) => {
})),
attachments,
captcha,
from,
),
);
setFormState({ type: FORM_STATES.loading });
Expand Down