Success messages on bulk actions
- added message for all bulk actions except trash related ones - fixed issue with mailpoet notice and react router
This commit is contained in:
@ -45,6 +45,10 @@ function(
|
||||
|
||||
data.action = this.state.action;
|
||||
|
||||
if(action['onSuccess'] !== undefined) {
|
||||
data.onSuccess = action.onSuccess;
|
||||
}
|
||||
|
||||
if(data.action) {
|
||||
this.props.onBulkAction(selected_ids, data);
|
||||
}
|
||||
|
@ -340,6 +340,11 @@ define(
|
||||
this.setState({ loading: true });
|
||||
|
||||
var data = params || {};
|
||||
var callback = ((data['onSuccess'] !== undefined)
|
||||
? data['onSuccess']
|
||||
: function() {}
|
||||
);
|
||||
delete data.onSuccess;
|
||||
|
||||
data.listing = {
|
||||
offset: 0,
|
||||
@ -354,8 +359,9 @@ define(
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'bulk_action',
|
||||
data: data
|
||||
}).done(function() {
|
||||
}).done(function(response) {
|
||||
this.getItems();
|
||||
callback(response);
|
||||
}.bind(this));
|
||||
},
|
||||
handleSearch: function(search) {
|
||||
|
@ -121,6 +121,22 @@ define('notice', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
||||
// set message
|
||||
this.setMessage(this.options.message);
|
||||
|
||||
// position notice
|
||||
this.element.insertAfter(jQuery('h2.title'));
|
||||
|
||||
// set class name
|
||||
switch(this.options.type) {
|
||||
case 'success':
|
||||
this.element.addClass('updated');
|
||||
break;
|
||||
case 'system':
|
||||
this.element.addClass('update-nag');
|
||||
break;
|
||||
case 'error':
|
||||
this.element.addClass('error');
|
||||
break;
|
||||
}
|
||||
|
||||
// make the notice appear
|
||||
this.element.fadeIn(200);
|
||||
|
||||
|
@ -77,6 +77,13 @@ define(
|
||||
return {
|
||||
segment_id: ~~(jQuery('#move_to_segment').val())
|
||||
}
|
||||
},
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
'%$1d subscribers were moved to list <strong>%$2s</strong>.'
|
||||
.replace('%$1d', ~~response.subscribers)
|
||||
.replace('%$2s', response.segment)
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -96,6 +103,13 @@ define(
|
||||
return {
|
||||
segment_id: ~~(jQuery('#add_to_segment').val())
|
||||
}
|
||||
},
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
'%$1d subscribers were added to list <strong>%$2s</strong>.'
|
||||
.replace('%$1d', ~~response.subscribers)
|
||||
.replace('%$2s', response.segment)
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -115,19 +129,45 @@ define(
|
||||
return {
|
||||
segment_id: ~~(jQuery('#remove_from_segment').val())
|
||||
}
|
||||
},
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
'%$1d subscribers were removed from list <strong>%$2s</strong>.'
|
||||
.replace('%$1d', ~~response.subscribers)
|
||||
.replace('%$2s', response.segment)
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'removeFromAllLists',
|
||||
label: 'Remove from all lists'
|
||||
label: 'Remove from all lists',
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
'%$1d subscribers were removed from all lists.'
|
||||
.replace('%$1d', ~~response.subscribers)
|
||||
.replace('%$2s', response.segment)
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'confirmUnconfirmed',
|
||||
label: 'Confirm unconfirmed'
|
||||
label: 'Confirm unconfirmed',
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
'%$1d subscribers have been confirmed.'
|
||||
.replace('%$1d', ~~response.subscribers)
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'trash',
|
||||
label: 'Trash'
|
||||
label: 'Trash',
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
'%$1d subscribers were moved to the trash.'
|
||||
.replace('%$1d', ~~response.subscribers)
|
||||
);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user