Add missing callbacks to ajax calls
[MAILPOET-982]
This commit is contained in:
@@ -9,7 +9,7 @@ function requestFailed(errorMessage, xhr) {
|
|||||||
message: message
|
message: message
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery, _) {
|
define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery, _) {
|
||||||
@@ -50,7 +50,7 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
|
|||||||
endpoint: this.options.endpoint,
|
endpoint: this.options.endpoint,
|
||||||
method: this.options.action,
|
method: this.options.action,
|
||||||
data: this.options.data || {}
|
data: this.options.data || {}
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
request: function(method, options) {
|
request: function(method, options) {
|
||||||
// set options
|
// set options
|
||||||
@@ -62,8 +62,8 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
|
|||||||
// remove null values from the data object
|
// remove null values from the data object
|
||||||
if (_.isObject(params.data)) {
|
if (_.isObject(params.data)) {
|
||||||
params.data = _.pick(params.data, function(value) {
|
params.data = _.pick(params.data, function(value) {
|
||||||
return (value !== null)
|
return (value !== null);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ajax request
|
// ajax request
|
||||||
|
@@ -487,7 +487,7 @@ const Listing = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).fail((response) => {
|
}).fail((response) => {
|
||||||
if (response.errors.length > 0) {
|
if(response.errors.length > 0) {
|
||||||
MailPoet.Notice.error(
|
MailPoet.Notice.error(
|
||||||
response.errors.map((error) => { return error.message; }),
|
response.errors.map((error) => { return error.message; }),
|
||||||
{ scroll: true }
|
{ scroll: true }
|
||||||
@@ -628,6 +628,13 @@ const Listing = React.createClass({
|
|||||||
data: data
|
data: data
|
||||||
}).done(() => {
|
}).done(() => {
|
||||||
this.getItems();
|
this.getItems();
|
||||||
|
}).fail((response) => {
|
||||||
|
if(response.errors.length > 0) {
|
||||||
|
MailPoet.Notice.error(
|
||||||
|
response.errors.map((error) => { return error.message; }),
|
||||||
|
{ scroll: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleSearch: function (search) {
|
handleSearch: function (search) {
|
||||||
|
@@ -129,6 +129,15 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
|||||||
jQuery('#stop-import').removeAttr('disabled'); // Enable the button
|
jQuery('#stop-import').removeAttr('disabled'); // Enable the button
|
||||||
MailPoet.MP2Migrator.reactivateImportButton();
|
MailPoet.MP2Migrator.reactivateImportButton();
|
||||||
MailPoet.MP2Migrator.updateDisplay(); // Get the latest information after the import was stopped
|
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();
|
MailPoet.MP2Migrator.stopLogger();
|
||||||
return false;
|
return false;
|
||||||
@@ -143,6 +152,15 @@ define('mp2migrator', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
|||||||
}
|
}
|
||||||
}).done(function () {
|
}).done(function () {
|
||||||
MailPoet.MP2Migrator.gotoWelcomePage();
|
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;
|
return false;
|
||||||
},
|
},
|
||||||
|
@@ -121,6 +121,13 @@ define(
|
|||||||
loading: false
|
loading: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}).fail((response) => {
|
||||||
|
if(response.errors.length > 0) {
|
||||||
|
MailPoet.Notice.error(
|
||||||
|
response.errors.map((error) => { return error.message; }),
|
||||||
|
{ scroll: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleSelectTemplate: function (template) {
|
handleSelectTemplate: function (template) {
|
||||||
@@ -169,6 +176,13 @@ define(
|
|||||||
}
|
}
|
||||||
}).done(() => {
|
}).done(() => {
|
||||||
this.getTemplates();
|
this.getTemplates();
|
||||||
|
}).fail((response) => {
|
||||||
|
if (response.errors.length > 0) {
|
||||||
|
MailPoet.Notice.error(
|
||||||
|
response.errors.map((error) => { return error.message; }),
|
||||||
|
{ scroll: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({ loading: false });
|
this.setState({ loading: false });
|
||||||
|
@@ -164,6 +164,14 @@ const item_actions = [
|
|||||||
);
|
);
|
||||||
refresh();
|
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) {
|
display: function (segment) {
|
||||||
|
@@ -84,6 +84,13 @@ class Widget extends \WP_Widget {
|
|||||||
window.location =
|
window.location =
|
||||||
"<?php echo $form_edit_url; ?>" + response.data.id;
|
"<?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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -124,6 +124,13 @@ jQuery(function($) {
|
|||||||
data: {
|
data: {
|
||||||
analytics: { enabled: (is_enabled)}
|
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) {
|
if (is_enabled) {
|
||||||
|
Reference in New Issue
Block a user