Updated all React components to their latest version

- updated code due to deprecated warnings (mostly router stuff & input default value)
- set default sender based on settings when creating new newsletter
- fixed erroneous UTC offset when displaying dates (PHP takes care of it)
This commit is contained in:
Jonathan Labreuille
2016-04-28 16:54:43 +02:00
parent 59199140bf
commit 4047b41a7f
26 changed files with 128 additions and 109 deletions

View File

@@ -7,7 +7,10 @@ function(
var FormFieldText = React.createClass({
render: function() {
var value = this.props.item[this.props.field.name];
if(!value) { value = null; }
if(value === undefined) {
value = this.props.field.defaultValue || '';
}
return (
<input
type="text"
@@ -21,7 +24,6 @@ function(
id={ 'field_'+this.props.field.name }
value={ value }
placeholder={ this.props.field.placeholder }
defaultValue={ this.props.field.defaultValue }
onChange={ this.props.onValueChange }
{...this.props.field.validation}
/>

View File

@@ -13,10 +13,11 @@ define(
Router,
FormField
) {
var Form = React.createClass({
mixins: [
Router.History
],
contextTypes: {
router: React.PropTypes.object.isRequired
},
getDefaultProps: function() {
return {
params: {},
@@ -68,7 +69,7 @@ define(
loading: false,
item: {}
}, function() {
this.history.pushState(null, '/new');
this.context.router.push('/new');
}.bind(this));
} else {
this.setState({
@@ -118,7 +119,16 @@ define(
if(this.props.onSuccess !== undefined) {
this.props.onSuccess();
} else {
this.history.pushState(null, '/')
var isChrome = (/Chrome/.test(navigator.userAgent))
&& (/Google Inc/.test(navigator.vendor));
if(
(isChrome && history.length > 2)
|| (!isChrome && history.length > 1)
) {
this.context.router.goBack();
} else {
this.context.router.push('/');
}
}
if(this.props.params.id !== undefined) {