- Enforces CSV file extension during import file selection

- Updates "no records found" error message
This commit is contained in:
Vlad
2016-01-20 15:25:37 -05:00
parent 7bd25660df
commit 1da28b7299
3 changed files with 17 additions and 5 deletions

View File

@ -138,6 +138,14 @@ define(
*/
uploadElement.change(function () {
MailPoet.Notice.hide();
var ext = this.value.match(/\.(.+)$/)[1];
if (ext.toLowerCase() !== 'csv') {
this.value = '';
MailPoet.Notice.error(MailPoetI18n.wrongFileFormat, {
timeout: 3000,
});
}
toggleNextStepButton(
uploadProcessButtonElement,
(this.value.trim() !== '') ? 'on' : 'off'
@ -416,7 +424,10 @@ define(
}
else {
MailPoet.Modal.loading(false);
MailPoet.Notice.error(MailPoetI18n.noValidRecords, {
var errorNotice = MailPoetI18n.noValidRecords;
errorNotice = errorNotice.replace('[link]', '<a target="_blank" href="http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file?utm_source=wpadmin&utm_campaign=import">');
errorNotice = errorNotice.replace('[/link]', '</a>');
MailPoet.Notice.error(errorNotice, {
timeout: 3000,
});
}

View File

@ -19,9 +19,10 @@
'noMailChimpLists': __('No active lists found.'),
'serverError': __('Server error:'),
'select': __('Select'),
'wrongFileFormat': __('Only comma-separated (CSV) file format is supported.'),
'maxPostSizeNotice': __('Your CSV is over %s, and too big to process. Please split the file in two, or more.')|replace({'%s': maxPostSize}),
'dataProcessingError': __("Your data couldn't be processed. Please make sure it is in the proper format."),
'noValidRecords': __('No valid records were found.'),
'noValidRecords': __('No valid records were found. This needs to be in CSV style. See [link]examples in our support site[/link]'),
'importNoticeSkipped': __('%1$s records were skipped due to problems.'),
'importNoticeInvalid': __('%1$s emails are not valid : %2$s.'),
'importNoticeDuplicate': __('%1$s emails appear more than once in your file : %2$s.'),

View File

@ -33,7 +33,7 @@
<%=
__('This needs to be in CSV style. See [link]examples in our support site[/link].')
|replace({
'[link]': '<a target="_blank" href="http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file/main.html?utm_source=wpadmin&utm_campaign=import">',
'[link]': '<a target="_blank" href="http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file?utm_source=wpadmin&utm_campaign=import">',
'[/link]': '</a>'
})
|raw
@ -65,7 +65,7 @@
<%=
__('This needs to be in CSV style. See [link]examples in our support site[/link].')
|replace({
'[link]': '<a target="_blank" href="http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file/main.html?utm_source=wpadmin&utm_campaign=import">',
'[link]': '<a target="_blank" href="http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file?utm_source=wpadmin&utm_campaign=import">',
'[/link]': '</a>'
})
|raw
@ -74,7 +74,7 @@
</label>
</th>
<td>
<input type="file" id="file_local">
<input type="file" id="file_local" accept=".csv" />
&nbsp;
<%= __( 'total max upload file size : %s' )|replace({'%s': maxPostSize}) %>
</td>