diff --git a/assets/js/src/form/fields/select.jsx b/assets/js/src/form/fields/select.jsx index 6b4ddbe076..66c061db26 100644 --- a/assets/js/src/form/fields/select.jsx +++ b/assets/js/src/form/fields/select.jsx @@ -23,7 +23,9 @@ function( name={ this.props.field.name } id={ 'field_'+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} ); diff --git a/assets/js/src/form/fields/selection.jsx b/assets/js/src/form/fields/selection.jsx index 7979b1bf28..04beac95f3 100644 --- a/assets/js/src/form/fields/selection.jsx +++ b/assets/js/src/form/fields/selection.jsx @@ -123,6 +123,7 @@ function( placeholder={ this.props.field.placeholder } multiple={ this.props.field.multiple } defaultValue={ default_value } + {...this.props.field.validation} >{ options } ); } diff --git a/assets/js/src/form/fields/text.jsx b/assets/js/src/form/fields/text.jsx index 04fac47d08..ff8f214d80 100644 --- a/assets/js/src/form/fields/text.jsx +++ b/assets/js/src/form/fields/text.jsx @@ -6,6 +6,8 @@ function( ) { var FormFieldText = React.createClass({ render: function() { + var value = this.props.item[this.props.field.name]; + if(!value) { value = null; } return ( + onChange={ this.props.onValueChange } + {...this.props.field.validation} + /> ); } }); diff --git a/assets/js/src/form/form.jsx b/assets/js/src/form/form.jsx index 5ca7fdc936..da416f9937 100644 --- a/assets/js/src/form/form.jsx +++ b/assets/js/src/form/form.jsx @@ -68,12 +68,25 @@ define( handleSubmit: function(e) { e.preventDefault(); + // handle validation + if(this.props.isValid !== undefined) { + if(this.props.isValid() === false) { + return; + } + } + this.setState({ loading: true }); // only get values from displayed fields - item = {}; + var item = {}; this.props.fields.map(function(field) { - item[field.name] = this.state.item[field.name]; + 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]; + } }.bind(this)); // set id if specified diff --git a/assets/js/src/newsletters/send.jsx b/assets/js/src/newsletters/send.jsx index 0c9bcbc2d1..b1a8b6df1c 100644 --- a/assets/js/src/newsletters/send.jsx +++ b/assets/js/src/newsletters/send.jsx @@ -45,7 +45,7 @@ define( tip: "Name & email of yourself or your company.", fields: [ { - name: 'from_name', + name: 'sender_name', type: 'text', placeholder: 'John Doe', defaultValue: (settings.sender !== undefined) ? settings.sender.name : '', @@ -54,7 +54,7 @@ define( } }, { - name: 'from_email', + name: 'sender_address', type: 'text', placeholder: 'john.doe@email.com', defaultValue: (settings.sender !== undefined) ? settings.sender.address : '', @@ -75,12 +75,14 @@ define( { name: 'reply_to_name', 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', - 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(); } }, + isValid: function() { + return (jQuery('#mailpoet_newsletter').parsley().validate()); + }, render: function() { return (
renderer->render('newsletters.html', $data); } - function getQueueStatus($response, $data, $screen_id) { - if(isset($data['mailpoet'])) { - $response['mailpoet'] = array( - 'hello' => 'world' - ); - } - return $response; - } - function newletterEditor() { $data = array(); wp_enqueue_media(); diff --git a/lib/Config/Migrator.php b/lib/Config/Migrator.php index 1b6c19dbee..6c9618bdcc 100644 --- a/lib/Config/Migrator.php +++ b/lib/Config/Migrator.php @@ -84,6 +84,10 @@ class Migrator { 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'subject varchar(250) NOT NULL,', '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,', 'body longtext,', 'created_at TIMESTAMP NOT NULL DEFAULT 0,', diff --git a/views/settings/basics.html b/views/settings/basics.html index 1864612f13..170d6a1759 100644 --- a/views/settings/basics.html +++ b/views/settings/basics.html @@ -67,13 +67,13 @@