Fixed issue #305
- added validation on add/edit Custom Field for multiple values (select/radio) - disabled Remove link when only one value remains - Added confirmation message on Reinstall - Added missing period in Import
This commit is contained in:
@ -10,10 +10,13 @@ function(
|
||||
return this.props.onValueChange(e);
|
||||
},
|
||||
render: function() {
|
||||
const isChecked = !!(this.props.item[this.props.field.name]);
|
||||
if (this.props.field.values === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isChecked = !!(this.props.item[this.props.field.name]);
|
||||
const options = Object.keys(this.props.field.values).map(
|
||||
function(value, index) {
|
||||
(value, index) => {
|
||||
return (
|
||||
<p key={ 'checkbox-' + index }>
|
||||
<label>
|
||||
@ -29,7 +32,7 @@ function(
|
||||
</label>
|
||||
</p>
|
||||
);
|
||||
}.bind(this)
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -4,12 +4,15 @@ define([
|
||||
function(
|
||||
React
|
||||
) {
|
||||
var FormFieldRadio = React.createClass({
|
||||
const FormFieldRadio = React.createClass({
|
||||
render: function() {
|
||||
var selected_value = this.props.item[this.props.field.name];
|
||||
if (this.props.field.values === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var options = Object.keys(this.props.field.values).map(
|
||||
function(value, index) {
|
||||
const selected_value = this.props.item[this.props.field.name];
|
||||
const options = Object.keys(this.props.field.values).map(
|
||||
(value, index) => {
|
||||
return (
|
||||
<p key={ 'radio-' + index }>
|
||||
<label>
|
||||
@ -23,7 +26,7 @@ function(
|
||||
</label>
|
||||
</p>
|
||||
);
|
||||
}.bind(this)
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -4,10 +4,14 @@ define([
|
||||
function(
|
||||
React
|
||||
) {
|
||||
var FormFieldSelect = React.createClass({
|
||||
const FormFieldSelect = React.createClass({
|
||||
render: function() {
|
||||
var options =
|
||||
Object.keys(this.props.field.values).map(function(value, index) {
|
||||
if (this.props.field.values === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const options = Object.keys(this.props.field.values).map(
|
||||
(value, index) => {
|
||||
return (
|
||||
<option
|
||||
key={ 'option-' + index }
|
||||
@ -15,7 +19,7 @@ function(
|
||||
{ this.props.field.values[value] }
|
||||
</option>
|
||||
);
|
||||
}.bind(this)
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -6,9 +6,13 @@
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
var field_values = {{#if params.values}}{{{ json_encode params.values }}}{{else}}[]{{/if}},
|
||||
field_type = "{{ type }}",
|
||||
template = Handlebars.compile($('#field_settings_values_item').html());
|
||||
{{#if params.values}}
|
||||
var field_values = {{{ json_encode params.values }}};
|
||||
{{else}}
|
||||
var field_values = [{ value: '' }];
|
||||
{{/if}}
|
||||
var field_type = "{{ type }}";
|
||||
var template = Handlebars.compile($('#field_settings_values_item').html());
|
||||
|
||||
// set default value for checkbox type if there is no value defined
|
||||
if(field_type === 'checkbox' && field_values.length !== 1) {
|
||||
@ -51,6 +55,13 @@ jQuery(function($) {
|
||||
$(item).find('.is_checked').attr('name', 'params[values]['+index+'][is_checked]');
|
||||
$(item).find('.value').attr('name', 'params[values]['+index+'][value]');
|
||||
});
|
||||
|
||||
// hide remove button if only one item remains
|
||||
if ($('.mailpoet_multiple_values li').length > 1) {
|
||||
$('.mailpoet_multiple_values .remove').show();
|
||||
} else {
|
||||
$('.mailpoet_multiple_values .remove').hide();
|
||||
}
|
||||
}
|
||||
{{#ifCond type '!=' 'checkbox'}}
|
||||
$('.mailpoet_multiple_values').on('click', '.is_checked', function() {
|
||||
|
@ -7,7 +7,14 @@
|
||||
{{#if is_checked}}checked="checked"{{/if}} value="1"/>
|
||||
{{/ifCond}}
|
||||
|
||||
<input type="text" name="" class="value" value="{{ value }}" />
|
||||
<input
|
||||
type="text"
|
||||
name=""
|
||||
class="value"
|
||||
value="{{ value }}"
|
||||
data-parsley-errors-messages-disabled="true"
|
||||
data-parsley-required="true"
|
||||
/>
|
||||
|
||||
{{#ifCond type 'in' 'radio,select'}}
|
||||
<a class="remove" href="javascript:;"><%= __('Remove') %></a>
|
||||
|
@ -187,20 +187,25 @@
|
||||
jQuery(function($) {
|
||||
$(function() {
|
||||
$('#mailpoet_reinstall').on('click', function() {
|
||||
MailPoet.Ajax.post({
|
||||
'endpoint': 'setup',
|
||||
'action': 'reset'
|
||||
}).done(function(response) {
|
||||
if(response.result === true) {
|
||||
MailPoet.Notice.success(
|
||||
"<%= __('MailPoet has been reinstalled successfully using the same version. Settings and data have been deleted.') %>",
|
||||
{ scroll: true });
|
||||
} else {
|
||||
MailPoet.Notice.error(
|
||||
"<%= __('MailPoet could not be reinstalled. You might need to remove it manually first.') %>",
|
||||
{ scroll: true });
|
||||
}
|
||||
});
|
||||
if(confirm(
|
||||
"<%= __('If you confirm this, all your current MailPoet data will be erased (newsletters, statistics, subscribers, etc...)') %>"
|
||||
)) {
|
||||
MailPoet.Ajax.post({
|
||||
'endpoint': 'setup',
|
||||
'action': 'reset'
|
||||
}).done(function(response) {
|
||||
if(response.result === true) {
|
||||
MailPoet.Notice.success(
|
||||
"<%= __('MailPoet has been reinstalled successfully using the same version. Settings and data have been deleted.') %>",
|
||||
{ scroll: true });
|
||||
} else {
|
||||
MailPoet.Notice.error(
|
||||
"<%= __('MailPoet could not be reinstalled. You might need to remove it manually first.') %>",
|
||||
{ scroll: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -198,10 +198,10 @@
|
||||
<input id="new_column_name" type="text" name="name" value="{{ name }}"/>
|
||||
</p>
|
||||
<p class="mailpoet_validation_error" data-error="name_required">
|
||||
<%= __('You need to specify a name') %>
|
||||
<%= __('You need to specify a name.') %>
|
||||
</p>
|
||||
<p class="mailpoet_validation_error" data-error="name_not_unique">
|
||||
<%= __('This name is already taken') %>
|
||||
<%= __('This name is already taken.') %>
|
||||
</p>
|
||||
|
||||
<hr/>
|
||||
|
Reference in New Issue
Block a user