Listing: Empty trash button
This commit is contained in:
@ -1,10 +1,12 @@
|
|||||||
define([
|
define([
|
||||||
'react',
|
'react',
|
||||||
'jquery'
|
'jquery',
|
||||||
|
'mailpoet'
|
||||||
],
|
],
|
||||||
function(
|
function(
|
||||||
React,
|
React,
|
||||||
jQuery
|
jQuery,
|
||||||
|
MailPoet
|
||||||
) {
|
) {
|
||||||
var ListingFilters = React.createClass({
|
var ListingFilters = React.createClass({
|
||||||
handleFilterAction: function() {
|
handleFilterAction: function() {
|
||||||
@ -14,6 +16,9 @@ function(
|
|||||||
})
|
})
|
||||||
return this.props.onSelectFilter(filters);
|
return this.props.onSelectFilter(filters);
|
||||||
},
|
},
|
||||||
|
handleEmptyTrash: function() {
|
||||||
|
return this.props.onEmptyTrash();
|
||||||
|
},
|
||||||
getAvailableFilters: function() {
|
getAvailableFilters: function() {
|
||||||
let filters = this.props.filters;
|
let filters = this.props.filters;
|
||||||
|
|
||||||
@ -63,6 +68,7 @@ function(
|
|||||||
if (available_filters.length > 0) {
|
if (available_filters.length > 0) {
|
||||||
button = (
|
button = (
|
||||||
<input
|
<input
|
||||||
|
id="post-query-submit"
|
||||||
onClick={ this.handleFilterAction }
|
onClick={ this.handleFilterAction }
|
||||||
type="submit"
|
type="submit"
|
||||||
defaultValue="Filter"
|
defaultValue="Filter"
|
||||||
@ -70,10 +76,23 @@ function(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let empty_trash = false;
|
||||||
|
if (this.props.group === 'trash') {
|
||||||
|
empty_trash = (
|
||||||
|
<input
|
||||||
|
onClick={ this.handleEmptyTrash }
|
||||||
|
type="submit"
|
||||||
|
value="Empty Trash"
|
||||||
|
className="button"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="alignleft actions actions">
|
<div className="alignleft actions actions">
|
||||||
{ available_filters }
|
{ available_filters }
|
||||||
{ button }
|
{ button }
|
||||||
|
{ empty_trash }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -504,10 +504,21 @@ define(
|
|||||||
this.getItems();
|
this.getItems();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
handleEmptyTrash: function() {
|
||||||
|
this.handleBulkAction('all', {
|
||||||
|
action: 'delete',
|
||||||
|
group: 'trash'
|
||||||
|
}, function(response) {
|
||||||
|
MailPoet.Notice.success(
|
||||||
|
MailPoetI18n.permanentlyDeleted.replace('%d', response)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
handleBulkAction: function(selected_ids, params, callback) {
|
handleBulkAction: function(selected_ids, params, callback) {
|
||||||
if(
|
if(
|
||||||
this.state.selection === false
|
this.state.selection === false
|
||||||
&& this.state.selected_ids.length === 0
|
&& this.state.selected_ids.length === 0
|
||||||
|
&& selected_ids !== 'all'
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -520,8 +531,10 @@ define(
|
|||||||
limit: 0,
|
limit: 0,
|
||||||
filter: this.state.filter,
|
filter: this.state.filter,
|
||||||
group: this.state.group,
|
group: this.state.group,
|
||||||
search: this.state.search,
|
search: this.state.search
|
||||||
selection: selected_ids
|
}
|
||||||
|
if(selected_ids !== 'all') {
|
||||||
|
data.listing.selection = selected_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
MailPoet.Ajax.post({
|
MailPoet.Ajax.post({
|
||||||
@ -715,7 +728,10 @@ define(
|
|||||||
<ListingFilters
|
<ListingFilters
|
||||||
filters={ this.state.filters }
|
filters={ this.state.filters }
|
||||||
filter={ this.state.filter }
|
filter={ this.state.filter }
|
||||||
onSelectFilter={ this.handleFilter } />
|
group={ this.state.group }
|
||||||
|
onSelectFilter={ this.handleFilter }
|
||||||
|
onEmptyTrash={ this.handleEmptyTrash }
|
||||||
|
/>
|
||||||
<ListingPages
|
<ListingPages
|
||||||
count={ this.state.count }
|
count={ this.state.count }
|
||||||
page={ this.state.page }
|
page={ this.state.page }
|
||||||
|
@ -60,7 +60,7 @@ class Model extends \Sudzy\ValidModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function bulkDelete($orm) {
|
static function bulkDelete($orm) {
|
||||||
$models = $orm->findMany();
|
$models = $orm->findResultSet();
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach($models as $model) {
|
foreach($models as $model) {
|
||||||
$model->delete();
|
$model->delete();
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
'pageTitle': __('Forms'),
|
'pageTitle': __('Forms'),
|
||||||
'searchLabel': __('Search'),
|
'searchLabel': __('Search'),
|
||||||
'loadingItems': __('Loading forms...'),
|
'loadingItems': __('Loading forms...'),
|
||||||
'noItemsFound': __('No forms found.')
|
'noItemsFound': __('No forms found.'),
|
||||||
|
'permanentlyDeleted': __('%d forms permanently deleted.')
|
||||||
}) %>
|
}) %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
'selectAllLabel': __('All newsletters on this page are selected.'),
|
'selectAllLabel': __('All newsletters on this page are selected.'),
|
||||||
'selectedAllLabel': __('All %d newsletters are selected.'),
|
'selectedAllLabel': __('All %d newsletters are selected.'),
|
||||||
'selectAllLink': __('Select all pages.'),
|
'selectAllLink': __('Select all pages.'),
|
||||||
'clearSelection': __('Clear selection.')
|
'clearSelection': __('Clear selection.'),
|
||||||
|
'permanentlyDeleted': __('%d newsletters permanently deleted.')
|
||||||
}) %>
|
}) %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
'pageTitle': __('Segments'),
|
'pageTitle': __('Segments'),
|
||||||
'searchLabel': __('Search'),
|
'searchLabel': __('Search'),
|
||||||
'loadingItems': __('Loading segments...'),
|
'loadingItems': __('Loading segments...'),
|
||||||
'noItemsFound': __('No segments found.')
|
'noItemsFound': __('No segments found.'),
|
||||||
|
'permanentlyDeleted': __('%d segments permanently deleted.')
|
||||||
}) %>
|
}) %>
|
||||||
<% endblock %>
|
<% endblock %>
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
'selectAllLabel': __('All subscribers on this page are selected.'),
|
'selectAllLabel': __('All subscribers on this page are selected.'),
|
||||||
'selectedAllLabel': __('All %d subscribers are selected.'),
|
'selectedAllLabel': __('All %d subscribers are selected.'),
|
||||||
'selectAllLink': __('Select all pages.'),
|
'selectAllLink': __('Select all pages.'),
|
||||||
'clearSelection': __('Clear selection.')
|
'clearSelection': __('Clear selection.'),
|
||||||
|
'permanentlyDeleted': __('%d subscribers permanently deleted.')
|
||||||
}) %>
|
}) %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
Reference in New Issue
Block a user