- 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;
|
||||
}
|
||||
|
||||
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) => {
|
||||
return (
|
||||
<option
|
||||
|
@@ -14,6 +14,11 @@ function(
|
||||
return (
|
||||
<input
|
||||
type="text"
|
||||
disabled={
|
||||
(this.props.field.disabled !== undefined)
|
||||
? this.props.field.disabled(this.props.item)
|
||||
: ''
|
||||
}
|
||||
className={ (this.props.field.size) ? '' : 'regular-text' }
|
||||
size={
|
||||
(this.props.field.size !== 'auto' && this.props.field.size > 0)
|
||||
|
@@ -167,6 +167,14 @@ define(
|
||||
{ '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) {
|
||||
return (
|
||||
<FormField
|
||||
@@ -191,26 +199,30 @@ define(
|
||||
}
|
||||
|
||||
return (
|
||||
<form
|
||||
id={ this.props.id }
|
||||
ref="form"
|
||||
className={ formClasses }
|
||||
onSubmit={
|
||||
(this.props.onSubmit !== undefined)
|
||||
? this.props.onSubmit
|
||||
: this.handleSubmit
|
||||
}
|
||||
>
|
||||
{ errors }
|
||||
<div>
|
||||
{ beforeFormContent }
|
||||
<form
|
||||
id={ this.props.id }
|
||||
ref="form"
|
||||
className={ formClasses }
|
||||
onSubmit={
|
||||
(this.props.onSubmit !== undefined)
|
||||
? this.props.onSubmit
|
||||
: this.handleSubmit
|
||||
}
|
||||
>
|
||||
{ errors }
|
||||
|
||||
<table className="form-table">
|
||||
<tbody>
|
||||
{fields}
|
||||
</tbody>
|
||||
</table>
|
||||
<table className="form-table">
|
||||
<tbody>
|
||||
{fields}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{ actions }
|
||||
</form>
|
||||
{ actions }
|
||||
</form>
|
||||
{ afterFormContent }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@@ -15,17 +15,26 @@ define(
|
||||
{
|
||||
name: 'email',
|
||||
label: MailPoet.I18n.t('email'),
|
||||
type: 'text'
|
||||
type: 'text',
|
||||
disabled: function(subscriber) {
|
||||
if (subscriber.wp_user_id !== null) return 'disabled';
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'first_name',
|
||||
label: MailPoet.I18n.t('firstname'),
|
||||
type: 'text'
|
||||
type: 'text',
|
||||
disabled: function(subscriber) {
|
||||
if (subscriber.wp_user_id !== null) return 'disabled';
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'last_name',
|
||||
label: MailPoet.I18n.t('lastname'),
|
||||
type: 'text'
|
||||
type: 'text',
|
||||
disabled: function(subscriber) {
|
||||
if (subscriber.wp_user_id !== null) return 'disabled';
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'status',
|
||||
@@ -35,6 +44,12 @@ define(
|
||||
'unconfirmed': MailPoet.I18n.t('unconfirmed'),
|
||||
'subscribed': MailPoet.I18n.t('subscribed'),
|
||||
'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 SubscriberForm = React.createClass({
|
||||
@@ -128,6 +155,7 @@ define(
|
||||
fields={ fields }
|
||||
params={ this.props.params }
|
||||
messages={ messages }
|
||||
beforeFormContent={ beforeFormContent }
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@@ -76,6 +76,7 @@
|
||||
'resendConfirmationEmail': __('Resend confirmation email'),
|
||||
'multipleConfirmationEmailsSent': __('%$1d confirmation emails have been sent.'),
|
||||
'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'),
|
||||
'import': __('Import'),
|
||||
'export': __('Export'),
|
||||
|
Reference in New Issue
Block a user