Merge pull request #218 from mailpoet/listings_bugfix

Listings bugfixes & Welcome page
This commit is contained in:
Marco
2015-11-13 16:01:23 +01:00
13 changed files with 79 additions and 101 deletions

View File

@@ -90,15 +90,15 @@ define(
if(response.result === true) {
if(this.props.onSuccess !== undefined) {
this.props.onSuccess()
this.props.onSuccess();
} else {
this.history.pushState(null, '/')
}
if(this.props.params.id !== undefined) {
this.props.messages['updated']();
this.props.messages.onUpdate();
} else {
this.props.messages['created']();
this.props.messages.onCreate();
}
} else {
if(response.result === false) {

View File

@@ -1,57 +0,0 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { Router, History } from 'react-router'
import MailPoet from 'mailpoet'
import Form from 'form/form.jsx'
const fields = [
{
name: 'name',
label: 'Name',
type: 'text'
},
{
name: 'segments',
label: 'Lists',
type: 'selection',
endpoint: 'segments',
multiple: true
}
]
const messages = {
updated: function() {
MailPoet.Notice.success('Form successfully updated!');
},
created: function() {
MailPoet.Notice.success('Form successfully added!');
}
}
const FormForm = React.createClass({
mixins: [
History
],
render() {
return (
<div>
<h2 className="title">
Form <a
href="javascript:;"
className="add-new-h2"
onClick={ this.history.goBack }
>Back to list</a>
</h2>
<Form
endpoint="forms"
fields={ fields }
params={ this.props.params }
messages={ messages }
onSuccess={ this.history.goBack } />
</div>
);
}
});
module.exports = FormForm

View File

@@ -2,7 +2,6 @@ import React from 'react'
import ReactDOM from 'react-dom'
import { Router, Route, IndexRoute } from 'react-router'
import FormList from 'forms/list.jsx'
import FormForm from 'forms/form.jsx'
import createHashHistory from 'history/lib/createHashHistory'
let history = createHashHistory({ queryKey: false })
@@ -20,8 +19,6 @@ if(container) {
<Router history={ history }>
<Route path="/" component={ App }>
<IndexRoute component={ FormList } />
<Route path="new" component={ FormForm } />
<Route path="edit/:id" component={ FormForm } />
<Route path="*" component={ FormList } />
</Route>
</Router>

View File

@@ -85,7 +85,12 @@ function(
Select bulk action
</label>
<select ref="action" value={ this.state.action } onChange={this.handleChangeAction}>
<select
name="bulk_actions"
ref="action"
value={ this.state.action }
onChange={this.handleChangeAction}
>
<option value="">Bulk Actions</option>
{ this.props.bulk_actions.map(function(action, index) {
return (

View File

@@ -11,7 +11,7 @@ define(['react', 'classnames'], function(React, classNames) {
column.is_primary = (index === 0);
column.sorted = (this.props.sort_by === column.name)
? this.props.sort_order
: 'asc';
: 'desc';
return (
<ListingColumn
onSort={this.props.onSort}
@@ -32,6 +32,7 @@ define(['react', 'classnames'], function(React, classNames) {
</label>
<input
type="checkbox"
name="select_all"
ref="toggle"
checked={ this.props.selection }
onChange={ this.handleSelectItems } />

View File

@@ -26,10 +26,10 @@ define(
];
var messages = {
updated: function() {
onUpdate: function() {
MailPoet.Notice.success('Segment successfully updated!');
},
created: function() {
onCreate: function() {
MailPoet.Notice.success('Segment successfully added!');
}
};
@@ -54,7 +54,7 @@ define(
fields={ fields }
params={ this.props.params }
messages={ messages }
onSuccess={ this.history.goBack } />
/>
</div>
);
}

View File

@@ -52,10 +52,10 @@ define(
];
var messages = {
updated: function() {
onUpdate: function() {
MailPoet.Notice.success('Subscriber successfully updated!');
},
created: function() {
onCreate: function() {
MailPoet.Notice.success('Subscriber successfully added!');
}
};
@@ -82,7 +82,7 @@ define(
fields={ fields }
params={ this.props.params }
messages={ messages }
onSuccess={ this.history.goBack } />
/>
</div>
);
}