Step 3 sender and reply to per newsletter
- added sender_address/sender_name/reply_to_address/reply_to_name - added validation on all form fields (except checkbox and radio)
This commit is contained in:
@ -23,7 +23,9 @@ function(
|
|||||||
name={ this.props.field.name }
|
name={ this.props.field.name }
|
||||||
id={ 'field_'+this.props.field.name }
|
id={ 'field_'+this.props.field.name }
|
||||||
value={ this.props.item[this.props.field.name] }
|
value={ this.props.item[this.props.field.name] }
|
||||||
onChange={ this.props.onValueChange }>
|
onChange={ this.props.onValueChange }
|
||||||
|
{...this.props.field.validation}
|
||||||
|
>
|
||||||
{options}
|
{options}
|
||||||
</select>
|
</select>
|
||||||
);
|
);
|
||||||
|
@ -123,6 +123,7 @@ function(
|
|||||||
placeholder={ this.props.field.placeholder }
|
placeholder={ this.props.field.placeholder }
|
||||||
multiple={ this.props.field.multiple }
|
multiple={ this.props.field.multiple }
|
||||||
defaultValue={ default_value }
|
defaultValue={ default_value }
|
||||||
|
{...this.props.field.validation}
|
||||||
>{ options }</select>
|
>{ options }</select>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ function(
|
|||||||
) {
|
) {
|
||||||
var FormFieldText = React.createClass({
|
var FormFieldText = React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
|
var value = this.props.item[this.props.field.name];
|
||||||
|
if(!value) { value = null; }
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@ -17,7 +19,7 @@ function(
|
|||||||
}
|
}
|
||||||
name={ this.props.field.name }
|
name={ this.props.field.name }
|
||||||
id={ 'field_'+this.props.field.name }
|
id={ 'field_'+this.props.field.name }
|
||||||
value={ this.props.item[this.props.field.name] }
|
value={ value }
|
||||||
placeholder={ this.props.field.placeholder }
|
placeholder={ this.props.field.placeholder }
|
||||||
defaultValue={ this.props.field.defaultValue }
|
defaultValue={ this.props.field.defaultValue }
|
||||||
onChange={ this.props.onValueChange }
|
onChange={ this.props.onValueChange }
|
||||||
|
@ -15,7 +15,9 @@ function(
|
|||||||
value={ this.props.item[this.props.field.name] }
|
value={ this.props.item[this.props.field.name] }
|
||||||
placeholder={ this.props.field.placeholder }
|
placeholder={ this.props.field.placeholder }
|
||||||
defaultValue={ this.props.field.defaultValue }
|
defaultValue={ this.props.field.defaultValue }
|
||||||
onChange={ this.props.onValueChange } />
|
onChange={ this.props.onValueChange }
|
||||||
|
{...this.props.field.validation}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -68,12 +68,25 @@ define(
|
|||||||
handleSubmit: function(e) {
|
handleSubmit: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
// handle validation
|
||||||
|
if(this.props.isValid !== undefined) {
|
||||||
|
if(this.props.isValid() === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({ loading: true });
|
this.setState({ loading: true });
|
||||||
|
|
||||||
// only get values from displayed fields
|
// only get values from displayed fields
|
||||||
item = {};
|
var item = {};
|
||||||
this.props.fields.map(function(field) {
|
this.props.fields.map(function(field) {
|
||||||
|
if(field['fields'] !== undefined) {
|
||||||
|
field.fields.map(function(subfield) {
|
||||||
|
item[subfield.name] = this.state.item[subfield.name];
|
||||||
|
}.bind(this));
|
||||||
|
} else {
|
||||||
item[field.name] = this.state.item[field.name];
|
item[field.name] = this.state.item[field.name];
|
||||||
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
// set id if specified
|
// set id if specified
|
||||||
|
@ -45,7 +45,7 @@ define(
|
|||||||
tip: "Name & email of yourself or your company.",
|
tip: "Name & email of yourself or your company.",
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'from_name',
|
name: 'sender_name',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
placeholder: 'John Doe',
|
placeholder: 'John Doe',
|
||||||
defaultValue: (settings.sender !== undefined) ? settings.sender.name : '',
|
defaultValue: (settings.sender !== undefined) ? settings.sender.name : '',
|
||||||
@ -54,7 +54,7 @@ define(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'from_email',
|
name: 'sender_address',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
placeholder: 'john.doe@email.com',
|
placeholder: 'john.doe@email.com',
|
||||||
defaultValue: (settings.sender !== undefined) ? settings.sender.address : '',
|
defaultValue: (settings.sender !== undefined) ? settings.sender.address : '',
|
||||||
@ -75,12 +75,14 @@ define(
|
|||||||
{
|
{
|
||||||
name: 'reply_to_name',
|
name: 'reply_to_name',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
placeholder: 'John Doe'
|
placeholder: 'John Doe',
|
||||||
|
defaultValue: (settings.reply_to !== undefined) ? settings.reply_to.name : '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'reply_to_email',
|
name: 'reply_to_address',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
placeholder: 'john.doe@email.com'
|
placeholder: 'john.doe@email.com',
|
||||||
|
defaultValue: (settings.reply_to !== undefined) ? settings.reply_to.address : ''
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -135,6 +137,9 @@ define(
|
|||||||
jQuery('#mailpoet_newsletter').parsley();
|
jQuery('#mailpoet_newsletter').parsley();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
isValid: function() {
|
||||||
|
return (jQuery('#mailpoet_newsletter').parsley().validate());
|
||||||
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -147,7 +152,8 @@ define(
|
|||||||
endpoint="newsletters"
|
endpoint="newsletters"
|
||||||
fields={ fields }
|
fields={ fields }
|
||||||
params={ this.props.params }
|
params={ this.props.params }
|
||||||
messages={ messages }>
|
messages={ messages }
|
||||||
|
isValid={ this.isValid }>
|
||||||
|
|
||||||
<p className="submit">
|
<p className="submit">
|
||||||
<input
|
<input
|
||||||
|
@ -320,8 +320,6 @@ class Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function newsletters() {
|
function newsletters() {
|
||||||
add_filter('heartbeat_received', array($this, 'getQueueStatus'), 10, 3);
|
|
||||||
|
|
||||||
global $wp_roles;
|
global $wp_roles;
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
@ -332,15 +330,6 @@ class Menu {
|
|||||||
echo $this->renderer->render('newsletters.html', $data);
|
echo $this->renderer->render('newsletters.html', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQueueStatus($response, $data, $screen_id) {
|
|
||||||
if(isset($data['mailpoet'])) {
|
|
||||||
$response['mailpoet'] = array(
|
|
||||||
'hello' => 'world'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
function newletterEditor() {
|
function newletterEditor() {
|
||||||
$data = array();
|
$data = array();
|
||||||
wp_enqueue_media();
|
wp_enqueue_media();
|
||||||
|
@ -84,6 +84,10 @@ class Migrator {
|
|||||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||||
'subject varchar(250) NOT NULL,',
|
'subject varchar(250) NOT NULL,',
|
||||||
'type varchar(20) NOT NULL DEFAULT "standard",',
|
'type varchar(20) NOT NULL DEFAULT "standard",',
|
||||||
|
'sender_address varchar(150) NOT NULL,',
|
||||||
|
'sender_name varchar(150) NOT NULL,',
|
||||||
|
'reply_to_address varchar(150) NOT NULL,',
|
||||||
|
'reply_to_name varchar(150) NOT NULL,',
|
||||||
'preheader varchar(250) NOT NULL,',
|
'preheader varchar(250) NOT NULL,',
|
||||||
'body longtext,',
|
'body longtext,',
|
||||||
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||||
|
@ -67,13 +67,13 @@
|
|||||||
<label for="settings[notification_reply_name]"><%= __('Reply-to') %></label>
|
<label for="settings[notification_reply_name]"><%= __('Reply-to') %></label>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
id="settings[notification_reply_name]"
|
id="settings[notification_reply_name]"
|
||||||
name="notification[reply_to][name]"
|
name="reply_to[name]"
|
||||||
value="<%= settings.notification.reply_to.name %>"
|
value="<%= settings.reply_to.name %>"
|
||||||
placeholder="<%= __('Your name') %>" />
|
placeholder="<%= __('Your name') %>" />
|
||||||
<input type="text"
|
<input type="text"
|
||||||
id="settings[notification_reply_email]"
|
id="settings[notification_reply_email]"
|
||||||
name="notification[reply_to][address]"
|
name="reply_to[address]"
|
||||||
value="<%= settings.notification.reply_to.address %>"
|
value="<%= settings.reply_to.address %>"
|
||||||
placeholder="info@mydomain.com" />
|
placeholder="info@mydomain.com" />
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
|
Reference in New Issue
Block a user