- Disables input fields if subscriber is a WP user. #421 (5)
- Removes 'unconfirmed' status if subscriber is a WP user. #421 (9) - Displays notice if subscriber is a WP user. #421 (6)
This commit is contained in:
@@ -10,7 +10,11 @@ function(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = Object.keys(this.props.field.values).map(
|
var values = (this.props.field.filterValues !== undefined)
|
||||||
|
? this.props.field.filterValues(this.props.item)
|
||||||
|
: this.props.field.values;
|
||||||
|
|
||||||
|
const options = Object.keys(values).map(
|
||||||
(value, index) => {
|
(value, index) => {
|
||||||
return (
|
return (
|
||||||
<option
|
<option
|
||||||
|
@@ -14,6 +14,11 @@ function(
|
|||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
disabled={
|
||||||
|
(this.props.field.disabled !== undefined)
|
||||||
|
? this.props.field.disabled(this.props.item)
|
||||||
|
: ''
|
||||||
|
}
|
||||||
className={ (this.props.field.size) ? '' : 'regular-text' }
|
className={ (this.props.field.size) ? '' : 'regular-text' }
|
||||||
size={
|
size={
|
||||||
(this.props.field.size !== 'auto' && this.props.field.size > 0)
|
(this.props.field.size !== 'auto' && this.props.field.size > 0)
|
||||||
|
@@ -167,6 +167,14 @@ define(
|
|||||||
{ 'mailpoet_form_loading': this.state.loading || this.props.loading }
|
{ 'mailpoet_form_loading': this.state.loading || this.props.loading }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this.props.beforeFormContent !== undefined) {
|
||||||
|
var beforeFormContent = this.props.beforeFormContent(this.getValues())
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.props.afterFormContent !== undefined) {
|
||||||
|
var afterFormContent = this.props.afterFormContent(this.getValues())
|
||||||
|
}
|
||||||
|
|
||||||
var fields = this.props.fields.map(function(field, i) {
|
var fields = this.props.fields.map(function(field, i) {
|
||||||
return (
|
return (
|
||||||
<FormField
|
<FormField
|
||||||
@@ -191,26 +199,30 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form
|
<div>
|
||||||
id={ this.props.id }
|
{ beforeFormContent }
|
||||||
ref="form"
|
<form
|
||||||
className={ formClasses }
|
id={ this.props.id }
|
||||||
onSubmit={
|
ref="form"
|
||||||
(this.props.onSubmit !== undefined)
|
className={ formClasses }
|
||||||
? this.props.onSubmit
|
onSubmit={
|
||||||
: this.handleSubmit
|
(this.props.onSubmit !== undefined)
|
||||||
}
|
? this.props.onSubmit
|
||||||
>
|
: this.handleSubmit
|
||||||
{ errors }
|
}
|
||||||
|
>
|
||||||
|
{ errors }
|
||||||
|
|
||||||
<table className="form-table">
|
<table className="form-table">
|
||||||
<tbody>
|
<tbody>
|
||||||
{fields}
|
{fields}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{ actions }
|
{ actions }
|
||||||
</form>
|
</form>
|
||||||
|
{ afterFormContent }
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -15,17 +15,26 @@ define(
|
|||||||
{
|
{
|
||||||
name: 'email',
|
name: 'email',
|
||||||
label: MailPoet.I18n.t('email'),
|
label: MailPoet.I18n.t('email'),
|
||||||
type: 'text'
|
type: 'text',
|
||||||
|
disabled: function(subscriber) {
|
||||||
|
if (subscriber.wp_user_id !== null) return 'disabled';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'first_name',
|
name: 'first_name',
|
||||||
label: MailPoet.I18n.t('firstname'),
|
label: MailPoet.I18n.t('firstname'),
|
||||||
type: 'text'
|
type: 'text',
|
||||||
|
disabled: function(subscriber) {
|
||||||
|
if (subscriber.wp_user_id !== null) return 'disabled';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'last_name',
|
name: 'last_name',
|
||||||
label: MailPoet.I18n.t('lastname'),
|
label: MailPoet.I18n.t('lastname'),
|
||||||
type: 'text'
|
type: 'text',
|
||||||
|
disabled: function(subscriber) {
|
||||||
|
if (subscriber.wp_user_id !== null) return 'disabled';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'status',
|
name: 'status',
|
||||||
@@ -35,6 +44,12 @@ define(
|
|||||||
'unconfirmed': MailPoet.I18n.t('unconfirmed'),
|
'unconfirmed': MailPoet.I18n.t('unconfirmed'),
|
||||||
'subscribed': MailPoet.I18n.t('subscribed'),
|
'subscribed': MailPoet.I18n.t('subscribed'),
|
||||||
'unsubscribed': MailPoet.I18n.t('unsubscribed')
|
'unsubscribed': MailPoet.I18n.t('unsubscribed')
|
||||||
|
},
|
||||||
|
filterValues: function(subscriber) {
|
||||||
|
if (subscriber.wp_user_id !== null) {
|
||||||
|
delete this.values.unconfirmed;
|
||||||
|
}
|
||||||
|
return this.values;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -112,6 +127,18 @@ define(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var beforeFormContent = function(subscriber) {
|
||||||
|
if (subscriber.wp_user_id !== null) {
|
||||||
|
var content =
|
||||||
|
'<p>' +
|
||||||
|
MailPoet.I18n.t('wordPressUserNotice')
|
||||||
|
.replace('[link]', '<a href="user-edit.php?user_id=' + subscriber.wp_user_id + '">')
|
||||||
|
.replace('[/link]', '</a>') +
|
||||||
|
'</p>';
|
||||||
|
return <div dangerouslySetInnerHTML={ {__html: content} } />
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var Link = Router.Link;
|
var Link = Router.Link;
|
||||||
|
|
||||||
var SubscriberForm = React.createClass({
|
var SubscriberForm = React.createClass({
|
||||||
@@ -128,6 +155,7 @@ define(
|
|||||||
fields={ fields }
|
fields={ fields }
|
||||||
params={ this.props.params }
|
params={ this.props.params }
|
||||||
messages={ messages }
|
messages={ messages }
|
||||||
|
beforeFormContent={ beforeFormContent }
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -76,6 +76,7 @@
|
|||||||
'resendConfirmationEmail': __('Resend confirmation email'),
|
'resendConfirmationEmail': __('Resend confirmation email'),
|
||||||
'multipleConfirmationEmailsSent': __('%$1d confirmation emails have been sent.'),
|
'multipleConfirmationEmailsSent': __('%$1d confirmation emails have been sent.'),
|
||||||
'listsToWhichSubscriberWasSubscribed': __('Lists to which the subscriber was subscribed.'),
|
'listsToWhichSubscriberWasSubscribed': __('Lists to which the subscriber was subscribed.'),
|
||||||
|
'wordPressUserNotice': __('This subscriber is a registered WordPress user. [link]Edit his profile[/link] to change his email.'),
|
||||||
'new': __('New'),
|
'new': __('New'),
|
||||||
'import': __('Import'),
|
'import': __('Import'),
|
||||||
'export': __('Export'),
|
'export': __('Export'),
|
||||||
|
Reference in New Issue
Block a user