Merge pull request #978 from mailpoet/add-missing-callbacks

Add missing callbacks to ajax calls [MAILPOET-982]
This commit is contained in:
mrcasual
2017-07-06 19:29:30 -04:00
committed by GitHub
7 changed files with 66 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ function requestFailed(errorMessage, xhr) {
message: message
}
]
}
};
}
define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery, _) {
@@ -50,7 +50,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
endpoint: this.options.endpoint,
method: this.options.action,
data: this.options.data || {}
}
};
},
request: function(method, options) {
// set options
@@ -62,8 +62,8 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
// remove null values from the data object
if (_.isObject(params.data)) {
params.data = _.pick(params.data, function(value) {
return (value !== null)
})
return (value !== null);
});
}
// ajax request

View File

@@ -487,7 +487,7 @@ const Listing = React.createClass({
}
});
}).fail((response) => {
if (response.errors.length > 0) {
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
@@ -628,6 +628,13 @@ const Listing = React.createClass({
data: data
}).done(() => {
this.getItems();
}).fail((response) => {
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
);
}
});
},
handleSearch: function (search) {

View File

@@ -129,6 +129,15 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
jQuery('#stop-import').removeAttr('disabled'); // Enable the button
MailPoet.MP2Migrator.reactivateImportButton();
MailPoet.MP2Migrator.updateDisplay(); // Get the latest information after the import was stopped
}).fail(function (response) {
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function (error) {
return error.message;
}),
{scroll: true}
);
}
});
MailPoet.MP2Migrator.stopLogger();
return false;
@@ -143,6 +152,15 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
}
}).done(function () {
MailPoet.MP2Migrator.gotoWelcomePage();
}).fail(function (response) {
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map(function (error) {
return error.message;
}),
{scroll: true}
);
}
});
return false;
},

View File

@@ -121,6 +121,13 @@ define(
loading: false
});
}
}).fail((response) => {
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
);
}
});
},
handleSelectTemplate: function (template) {
@@ -169,6 +176,13 @@ define(
}
}).done(() => {
this.getTemplates();
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
);
}
});
} else {
this.setState({ loading: false });

View File

@@ -164,6 +164,14 @@ const item_actions = [
);
refresh();
}
}).fail((response) => {
MailPoet.Modal.loading(false);
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
);
}
});
},
display: function (segment) {

View File

@@ -84,6 +84,13 @@ class Widget extends \WP_Widget {
window.location =
"<?php echo $form_edit_url; ?>" + response.data.id;
}
}).fail((response) => {
if(response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
);
}
});
return false;
}

View File

@@ -124,6 +124,13 @@ jQuery(function($) {
data: {
analytics: { enabled: (is_enabled)}
}
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => { return error.message; }),
{ scroll: true }
);
}
});
if (is_enabled) {