Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Updated EmailTool templating and documentation
Browse files Browse the repository at this point in the history
* Added new postal variable to mail templates
* Adding ability to include variables both in the subjects and body.
  • Loading branch information
rodrei committed Nov 28, 2017
1 parent 5b36002 commit 2ea4a45
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
7 changes: 5 additions & 2 deletions app/javascript/components/EmailEditor/EmailEditor.js
Expand Up @@ -30,8 +30,8 @@ export default class EmailEditor extends PureComponent {
constructor(props: Props) {
super(props);
this.state = {
subject: this.props.subject,
body: this.props.body,
subject: this.parse(this.props.subject),
body: this.parse(this.props.body),
};
}

Expand All @@ -48,6 +48,9 @@ export default class EmailEditor extends PureComponent {
}

parse(templateString?: string = ''): string {
if (!templateString) {
return '';
}
templateString = templateString.replace(/(?:\r\n|\r|\n)/g, '<br />');
return template(templateString)(this.props.templateVars);
}
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/email_tool/EmailToolView.js
Expand Up @@ -34,6 +34,7 @@ type Props = {
country: string,
email: string,
name: string,
postal: string,
isSubmitting: boolean,
page: string,
pageId: number,
Expand Down Expand Up @@ -152,6 +153,7 @@ export default class EmailToolView extends Component {
templateVars() {
return {
name: this.state.name,
postal: this.props.postal,
target: this.state.target,
};
}
Expand Down
1 change: 1 addition & 0 deletions app/javascript/packs/email_tool.js
Expand Up @@ -17,6 +17,7 @@ type Props = {
isSubmitting: boolean,
locale: string,
name?: string,
postal?: string,
page: string,
pageId: number,
targets: EmailTarget[],
Expand Down
1 change: 1 addition & 0 deletions app/views/plugins/email_pensions/_email_pension.liquid
Expand Up @@ -9,6 +9,7 @@
name: member.full_name,
email: member.email,
country: member.country,
postal: member.postal,
formValues: window.champaign.personalization.formValues
});
Expand Down
1 change: 1 addition & 0 deletions app/views/plugins/email_tools/_email_tool.liquid
Expand Up @@ -12,6 +12,7 @@
_.merge(data, {
name: personalization.member.full_name,
email: personalization.member.email,
postal: personalization.member.postal,
country: personalization.member.country || personalization.location.country,
trackingParams: trackingParams,
onSuccess: function (target) {
Expand Down
8 changes: 4 additions & 4 deletions app/views/plugins/email_tools/_form.slim
Expand Up @@ -3,7 +3,7 @@
- name = "plugins_email_tool_#{plugin.id}"
= form_for plugin, url: '#', remote: true, as: name, html: { class: 'form-element one-form' }, data: {type: name } do |f|
= render 'plugins/shared/plugin_metadata', f: f
.form-group
.form-group
= label_with_tooltip(f, :title, t('plugins.email_tool.title'), t('plugins.email_tool.tooltips.title'))
= f.text_field :title, class: 'form-control'
.form-group
Expand All @@ -28,15 +28,15 @@
= render 'plugins/shared/subject_editor', name: name, f: f, plugin: plugin

.form-group
= f.label(:email_body_header, t('plugins.email_tool.email_header'))
= label_with_tooltip f, :email_body_header, t('plugins.email_tool.email_header'), t('plugins.email_tool.tooltips.email_content')
= f.text_area :email_body_header, class: 'form-control height-short'

.form-group
= f.label(:email_body, t('plugins.email_tool.email_body'))
= label_with_tooltip f, :email_body, t('plugins.email_tool.email_body'), t('plugins.email_tool.tooltips.email_content')
= f.text_area :email_body, class: 'form-control height-large'

.form-group
= f.label(:email_body_footer, t('plugins.email_tool.email_footer'))
= label_with_tooltip f, :email_body_footer, t('plugins.email_tool.email_footer'), t('plugins.email_tool.tooltips.email_content')
= f.text_area :email_body_footer, class: 'form-control height-short'

.form-group
Expand Down
4 changes: 4 additions & 0 deletions config/locales/champaign.en.yml
Expand Up @@ -339,6 +339,10 @@ en:
use_member_email: "Emails sent to targets will use the member's email address in the `from` field"
from_address: "Email will be sent from this email address if \"Send from member's email address\" is unchecked. In any case, this address will also be used as a reply-to address."
email_address_for_testing: 'ALL emails will be delivered to this address - use when you want to test a campaign before publishing.'
email_content: "To use the member's name include a tag with the following format: ${name}. \
The available variables are: ${name}, ${postal}, ${target.email} and ${target.name}. Target's custom fields included in the CSV such as country \
and state, can be access with ${target.fields.country} and ${target.fields.state}."

call_tool:
title: 'Title'
click_to_play: 'Click to play'
Expand Down

0 comments on commit 2ea4a45

Please sign in to comment.