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);
|
return this.props.onValueChange(e);
|
||||||
},
|
},
|
||||||
render: function() {
|
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(
|
const options = Object.keys(this.props.field.values).map(
|
||||||
function(value, index) {
|
(value, index) => {
|
||||||
return (
|
return (
|
||||||
<p key={ 'checkbox-' + index }>
|
<p key={ 'checkbox-' + index }>
|
||||||
<label>
|
<label>
|
||||||
@ -29,7 +32,7 @@ function(
|
|||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
}.bind(this)
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -4,12 +4,15 @@ define([
|
|||||||
function(
|
function(
|
||||||
React
|
React
|
||||||
) {
|
) {
|
||||||
var FormFieldRadio = React.createClass({
|
const FormFieldRadio = React.createClass({
|
||||||
render: function() {
|
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(
|
const selected_value = this.props.item[this.props.field.name];
|
||||||
function(value, index) {
|
const options = Object.keys(this.props.field.values).map(
|
||||||
|
(value, index) => {
|
||||||
return (
|
return (
|
||||||
<p key={ 'radio-' + index }>
|
<p key={ 'radio-' + index }>
|
||||||
<label>
|
<label>
|
||||||
@ -23,7 +26,7 @@ function(
|
|||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
}.bind(this)
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -4,10 +4,14 @@ define([
|
|||||||
function(
|
function(
|
||||||
React
|
React
|
||||||
) {
|
) {
|
||||||
var FormFieldSelect = React.createClass({
|
const FormFieldSelect = React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
var options =
|
if (this.props.field.values === undefined) {
|
||||||
Object.keys(this.props.field.values).map(function(value, index) {
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = Object.keys(this.props.field.values).map(
|
||||||
|
(value, index) => {
|
||||||
return (
|
return (
|
||||||
<option
|
<option
|
||||||
key={ 'option-' + index }
|
key={ 'option-' + index }
|
||||||
@ -15,7 +19,7 @@ function(
|
|||||||
{ this.props.field.values[value] }
|
{ this.props.field.values[value] }
|
||||||
</option>
|
</option>
|
||||||
);
|
);
|
||||||
}.bind(this)
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -6,9 +6,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(function($) {
|
jQuery(function($) {
|
||||||
var field_values = {{#if params.values}}{{{ json_encode params.values }}}{{else}}[]{{/if}},
|
{{#if params.values}}
|
||||||
field_type = "{{ type }}",
|
var field_values = {{{ json_encode params.values }}};
|
||||||
template = Handlebars.compile($('#field_settings_values_item').html());
|
{{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
|
// set default value for checkbox type if there is no value defined
|
||||||
if(field_type === 'checkbox' && field_values.length !== 1) {
|
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('.is_checked').attr('name', 'params[values]['+index+'][is_checked]');
|
||||||
$(item).find('.value').attr('name', 'params[values]['+index+'][value]');
|
$(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'}}
|
{{#ifCond type '!=' 'checkbox'}}
|
||||||
$('.mailpoet_multiple_values').on('click', '.is_checked', function() {
|
$('.mailpoet_multiple_values').on('click', '.is_checked', function() {
|
||||||
|
@ -7,7 +7,14 @@
|
|||||||
{{#if is_checked}}checked="checked"{{/if}} value="1"/>
|
{{#if is_checked}}checked="checked"{{/if}} value="1"/>
|
||||||
{{/ifCond}}
|
{{/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'}}
|
{{#ifCond type 'in' 'radio,select'}}
|
||||||
<a class="remove" href="javascript:;"><%= __('Remove') %></a>
|
<a class="remove" href="javascript:;"><%= __('Remove') %></a>
|
||||||
|
@ -187,6 +187,9 @@
|
|||||||
jQuery(function($) {
|
jQuery(function($) {
|
||||||
$(function() {
|
$(function() {
|
||||||
$('#mailpoet_reinstall').on('click', function() {
|
$('#mailpoet_reinstall').on('click', function() {
|
||||||
|
if(confirm(
|
||||||
|
"<%= __('If you confirm this, all your current MailPoet data will be erased (newsletters, statistics, subscribers, etc...)') %>"
|
||||||
|
)) {
|
||||||
MailPoet.Ajax.post({
|
MailPoet.Ajax.post({
|
||||||
'endpoint': 'setup',
|
'endpoint': 'setup',
|
||||||
'action': 'reset'
|
'action': 'reset'
|
||||||
@ -201,6 +204,8 @@
|
|||||||
{ scroll: true });
|
{ scroll: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -198,10 +198,10 @@
|
|||||||
<input id="new_column_name" type="text" name="name" value="{{ name }}"/>
|
<input id="new_column_name" type="text" name="name" value="{{ name }}"/>
|
||||||
</p>
|
</p>
|
||||||
<p class="mailpoet_validation_error" data-error="name_required">
|
<p class="mailpoet_validation_error" data-error="name_required">
|
||||||
<%= __('You need to specify a name') %>
|
<%= __('You need to specify a name.') %>
|
||||||
</p>
|
</p>
|
||||||
<p class="mailpoet_validation_error" data-error="name_not_unique">
|
<p class="mailpoet_validation_error" data-error="name_not_unique">
|
||||||
<%= __('This name is already taken') %>
|
<%= __('This name is already taken.') %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
Reference in New Issue
Block a user