converted export
This commit is contained in:
@@ -133,8 +133,7 @@ define(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MailPoet.Modal.loading(true);
|
MailPoet.Modal.loading(true);
|
||||||
MailPoet.Ajax
|
MailPoet.Ajax.post({
|
||||||
.post({
|
|
||||||
endpoint: 'ImportExport',
|
endpoint: 'ImportExport',
|
||||||
action: 'processExport',
|
action: 'processExport',
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
@@ -144,25 +143,22 @@ define(
|
|||||||
'segments': (exportData.segments) ? segmentsContainerElement.val() : false,
|
'segments': (exportData.segments) ? segmentsContainerElement.val() : false,
|
||||||
'subscriber_fields': subscriberFieldsContainerElement.val()
|
'subscriber_fields': subscriberFieldsContainerElement.val()
|
||||||
})
|
})
|
||||||
})
|
}).always(function(response) {
|
||||||
.done(function (response) {
|
|
||||||
MailPoet.Modal.loading(false);
|
MailPoet.Modal.loading(false);
|
||||||
if (response.result === false) {
|
}).done(function(response) {
|
||||||
MailPoet.Notice.error(response.errors);
|
resultMessage = MailPoet.I18n.t('exportMessage')
|
||||||
} else {
|
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported).toLocaleString() + '</strong>')
|
||||||
resultMessage = MailPoet.I18n.t('exportMessage')
|
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
|
||||||
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported).toLocaleString() + '</strong>')
|
.replace('[/link]', '</a>');
|
||||||
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
|
jQuery('#export_result_notice').html('<p>' + resultMessage + '</p>').show();
|
||||||
.replace('[/link]', '</a>');
|
window.location.href = response.data.exportFileURL;
|
||||||
jQuery('#export_result_notice').html('<p>' + resultMessage + '</p>').show();
|
}).fail(function(response) {
|
||||||
window.location.href = response.data.exportFileURL;
|
if (response.errors.length > 0) {
|
||||||
|
MailPoet.Notice.error(
|
||||||
|
response.errors.map(function(error) { return error.message; }),
|
||||||
|
{ scroll: true }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.fail(function (error) {
|
|
||||||
MailPoet.Modal.loading(false);
|
|
||||||
MailPoet.Notice.error(
|
|
||||||
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -58,17 +58,11 @@ class Export {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
return array(
|
throw new \Exception($e->getMessage());
|
||||||
'result' => false,
|
|
||||||
'errors' => array($e->getMessage())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return array(
|
return array(
|
||||||
'result' => true,
|
'totalExported' => $processed_subscribers,
|
||||||
'data' => array(
|
'exportFileURL' => $this->export_file_URL
|
||||||
'totalExported' => $processed_subscribers,
|
|
||||||
'exportFileURL' => $this->export_file_URL
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user