Edit newsletter

- added custom item_actions to listings
- added special function in order to register pages that aren't present in the menu
- removed useless test.hbs
- added wp_nonce_field & params functions to Twig
- created a separate "newsletter/form.html" (copy of editor.html) but properly formatted
This commit is contained in:
Jonathan Labreuille
2015-09-25 10:25:50 +02:00
parent 14cf783544
commit 7562ac22ee
7 changed files with 1375 additions and 23 deletions

View File

@@ -69,13 +69,33 @@ define(
);
}
var item_actions = (
var custom_actions = this.props.item_actions;
var item_actions = false;
if(custom_actions.length > 0) {
item_actions = custom_actions.map(function(action, index) {
return (
<span key={ 'action-'+index } className={ action.name }>
<a href={ action.link(this.props.item.id) }>
{ action.label }
</a>
{(index < (custom_actions.length - 1)) ? ' | ' : ''}
</span>
);
}.bind(this));
} else {
item_actions = (
<span className="edit">
<Link to="edit" params={{ id: this.props.item.id }}>Edit</Link>
</span>
);
}
var actions = (
<div>
<div className="row-actions">
<span className="edit">
<Link to="edit" params={{ id: this.props.item.id }}>Edit</Link>
</span>
&nbsp;|&nbsp;
{ item_actions }
{ ' | ' }
<span className="trash">
<a
href="javascript:;"
@@ -97,7 +117,7 @@ define(
return (
<tr className={ row_classes }>
{ checkbox }
{ this.props.onRenderItem(this.props.item, item_actions) }
{ this.props.onRenderItem(this.props.item, actions) }
</tr>
);
}
@@ -166,6 +186,7 @@ define(
onDeleteItem={ this.props.onDeleteItem }
selection={ this.props.selection }
is_selectable={ this.props.is_selectable }
item_actions={ this.props.item_actions }
key={ 'item-' + item.id }
item={ item } />
);
@@ -367,6 +388,9 @@ define(
// bulk actions
var bulk_actions = this.props.bulk_actions || [];
// item actions
var item_actions = this.props.item_actions || [];
var tableClasses = classNames(
'wp-list-table',
'widefat',
@@ -420,6 +444,7 @@ define(
loading={ this.state.loading }
count={ this.state.count }
limit={ this.state.limit }
item_actions={ item_actions }
items={ items } />
<tfoot>

View File

@@ -34,8 +34,19 @@ define(
}
];
var item_actions = [
{
name: 'edit',
label: 'Edit',
link: function(id) {
return '?page=mailpoet-newsletter-editor&id='+parseInt(id, 10);
}
}
];
var NewsletterList = React.createClass({
renderItem: function(newsletter, actions) {
var rowClasses = classNames(
'manage-column',
'column-primary',
@@ -65,7 +76,8 @@ define(
endpoint="newsletters"
onRenderItem={this.renderItem}
columns={columns}
bulk_actions={ bulk_actions } />
bulk_actions={ bulk_actions }
item_actions={ item_actions } />
);
}
});