diff --git a/assets/js/src/listing/bulk_actions.jsx b/assets/js/src/listing/bulk_actions.jsx index a30b3c7981..8ce1f22a5e 100644 --- a/assets/js/src/listing/bulk_actions.jsx +++ b/assets/js/src/listing/bulk_actions.jsx @@ -32,9 +32,15 @@ function( e.preventDefault(); var action = this.getSelectedAction(); + + if(action === null) { + return; + } + var selected_ids = (this.props.selection !== 'all') ? this.props.selected_ids : []; + var data = (action['getData'] !== undefined) ? action.getData() : {}; @@ -78,17 +84,17 @@ function( diff --git a/assets/js/src/listing/listing.jsx b/assets/js/src/listing/listing.jsx index 2163667427..addeaab843 100644 --- a/assets/js/src/listing/listing.jsx +++ b/assets/js/src/listing/listing.jsx @@ -237,6 +237,10 @@ define( }.bind(this)); }, handleBulkAction: function(selected_ids, params) { + if(this.state.selection === false) { + return; + } + this.setState({ loading: true }); var data = params || {}; @@ -275,21 +279,29 @@ define( }.bind(this)); }, handleSelectItem: function(id, is_checked) { - var selected_ids = this.state.selected_ids; + var selected_ids = this.state.selected_ids, + selection = false; if(is_checked) { selected_ids = jQuery.merge(selected_ids, [ id ]); + // check whether all items on the page are selected + if( + jQuery('tbody .check-column :checkbox:not(:checked)').length === 0 + ) { + selection = 'page'; + } } else { selected_ids.splice(selected_ids.indexOf(id), 1); } this.setState({ - selection: false, + selection: selection, selected_ids: selected_ids }); }, handleSelectItems: function(is_checked) { if(is_checked === false) { + this.clearSelection(); } else { var selected_ids = this.state.items.map(function(item) { return ~~item.id; diff --git a/assets/js/src/subscribers/list.jsx b/assets/js/src/subscribers/list.jsx index 0424b2b863..c0fb1a11e3 100644 --- a/assets/js/src/subscribers/list.jsx +++ b/assets/js/src/subscribers/list.jsx @@ -1,6 +1,7 @@ define( [ 'react', + 'react-router', 'listing/listing.jsx', 'classnames', 'mailpoet', @@ -9,11 +10,14 @@ define( ], function( React, + Router, Listing, classNames, MailPoet, jQuery ) { + var Link = Router.Link; + var columns = [ { name: 'email', @@ -35,6 +39,12 @@ define( label: 'Status', sortable: true }, + { + name: 'lists', + label: 'Lists', + sortable: false + }, + { name: 'created_at', label: 'Subscribed on', @@ -57,7 +67,16 @@ define( } }, componentDidMount: function() { - this.loadItems(); + // this.loadItems(); + this.loadCachedItems(); + }, + loadCachedItems: function() { + if(typeof(window['mailpoet_'+this.props.endpoint]) !== 'undefined') { + var items = window['mailpoet_'+this.props.endpoint]; + this.setState({ + items: items + }); + } }, loadItems: function() { this.setState({ loading: true }); @@ -222,11 +241,19 @@ define( break; } + var segments = mailpoet_segments.filter(function(segment) { + return (jQuery.inArray(segment.id, subscriber.segments) !== -1); + }).map(function(segment) { + return segment.name; + }).join(', '); + return (