Refactor resume sending js code out of PHP

[MAILPOET-1987]
This commit is contained in:
Rostislav Wolny
2019-05-15 19:37:45 +02:00
committed by M. Shull
parent ced9c549f6
commit 3aa382a060
5 changed files with 17 additions and 20 deletions

View File

@@ -1,4 +1,5 @@
import jQuery from 'jquery';
import MailPoet from 'mailpoet';
jQuery(($) => {
$(document).on('click', '.mailpoet-dismissible-notice .notice-dismiss', function dismiss() {
@@ -12,4 +13,18 @@ jQuery(($) => {
},
});
});
$(document).on('click', '.notice .mailpoet-js-button-resume-sending', function resumeSending() {
const noticeElement = $(this).closest('.notice');
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'mailer',
action: 'resumeSending',
}).done(() => {
noticeElement.slideUp();
MailPoet.Notice.success(MailPoet.I18n.t('mailerSendingResumedNotice'));
if (window.mailpoet_listing) { window.mailpoet_listing.forceUpdate(); }
}).fail((response) => {
MailPoet.Notice.showApiErrorNotice(response, { scroll: true });
});
});
});