Segment actions
- added duplicate - added view subscribers
This commit is contained in:
@@ -79,7 +79,7 @@ define(
|
||||
item_actions = custom_actions.map(function(action, index) {
|
||||
return (
|
||||
<span key={ 'action-'+index } className={ action.name }>
|
||||
{ action.link(this.props.item.id) }
|
||||
{ action.link(this.props.item) }
|
||||
{(index < (custom_actions.length - 1)) ? ' | ' : ''}
|
||||
</span>
|
||||
);
|
||||
@@ -522,7 +522,6 @@ define(
|
||||
var bulk_actions = this.props.bulk_actions || [];
|
||||
|
||||
if(this.state.group === 'trash') {
|
||||
|
||||
bulk_actions = [
|
||||
{
|
||||
name: 'restore',
|
||||
@@ -574,6 +573,9 @@ define(
|
||||
groups = false;
|
||||
}
|
||||
|
||||
// filters
|
||||
var filter = this.state.filter;
|
||||
|
||||
return (
|
||||
<div>
|
||||
{ groups }
|
||||
@@ -586,7 +588,7 @@ define(
|
||||
onBulkAction={ this.handleBulkAction } />
|
||||
<ListingFilters
|
||||
filters={ this.state.filters }
|
||||
filter={ this.state.filter }
|
||||
filter={ filter }
|
||||
onSelectFilter={ this.handleFilter } />
|
||||
<ListingPages
|
||||
count={ this.state.count }
|
||||
|
@@ -3,13 +3,15 @@ define(
|
||||
'react',
|
||||
'react-router',
|
||||
'listing/listing.jsx',
|
||||
'classnames'
|
||||
'classnames',
|
||||
'mailpoet'
|
||||
],
|
||||
function(
|
||||
React,
|
||||
Router,
|
||||
Listing,
|
||||
classNames
|
||||
classNames,
|
||||
MailPoet
|
||||
) {
|
||||
var columns = [
|
||||
{
|
||||
@@ -49,10 +51,10 @@ define(
|
||||
var count = ~~response.segments;
|
||||
var message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if(count === 1 || response === true) {
|
||||
message = (
|
||||
'1 segment was moved to the trash.'
|
||||
).replace('%$1d', count);
|
||||
);
|
||||
} else if(count > 1) {
|
||||
message = (
|
||||
'%$1d segments were moved to the trash.'
|
||||
@@ -67,10 +69,10 @@ define(
|
||||
var count = ~~response.segments;
|
||||
var message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if(count === 1 || response === true) {
|
||||
message = (
|
||||
'1 segment was permanently deleted.'
|
||||
).replace('%$1d', count);
|
||||
);
|
||||
} else if(count > 1) {
|
||||
message = (
|
||||
'%$1d segments were permanently deleted.'
|
||||
@@ -85,10 +87,10 @@ define(
|
||||
var count = ~~response.segments;
|
||||
var message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if(count === 1 || response === true) {
|
||||
message = (
|
||||
'1 segment has been restored from the trash.'
|
||||
).replace('%$1d', count);
|
||||
);
|
||||
} else if(count > 1) {
|
||||
message = (
|
||||
'%$1d segments have been restored from the trash.'
|
||||
@@ -101,6 +103,48 @@ define(
|
||||
}
|
||||
};
|
||||
|
||||
var Link = Router.Link;
|
||||
var item_actions = [
|
||||
{
|
||||
name: 'edit',
|
||||
link: function(item) {
|
||||
return (
|
||||
<Link to={ `/edit/${item.id}` }>Edit</Link>
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'duplicate_segment',
|
||||
link: function(item) {
|
||||
return (
|
||||
<a
|
||||
href="javascript:;"
|
||||
onClick={ this.onDuplicate.bind(null, item) }
|
||||
>Duplicate</a>
|
||||
);
|
||||
},
|
||||
onDuplicate: function(item) {
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'segments',
|
||||
action: 'duplicate',
|
||||
data: item.id
|
||||
}).done(function() {
|
||||
MailPoet.Notice.success(
|
||||
('List "%$1s" has been duplicated.').replace('%$1s', item.name)
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'view_subscribers',
|
||||
link: function(item) {
|
||||
return (
|
||||
<a href={ item.subscribers_url }>View subscribers</a>
|
||||
);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
var bulk_actions = [
|
||||
{
|
||||
name: 'trash',
|
||||
@@ -164,7 +208,9 @@ define(
|
||||
endpoint="segments"
|
||||
onRenderItem={ this.renderItem }
|
||||
columns={ columns }
|
||||
bulk_actions={ bulk_actions } />
|
||||
bulk_actions={ bulk_actions }
|
||||
item_actions={ item_actions }
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@@ -258,8 +258,6 @@ define(
|
||||
return segment.name;
|
||||
}).join(', ');
|
||||
|
||||
var row_actions = false;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<td className={ row_classes }>
|
||||
|
@@ -9,7 +9,7 @@ let history = createHashHistory({ queryKey: false })
|
||||
|
||||
const App = React.createClass({
|
||||
render() {
|
||||
return this.props.children
|
||||
return this.props.children;
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user