Some fixes

This commit is contained in:
Tomas Bures 2019-05-20 00:38:39 +02:00
parent 3c72e778d9
commit 640d3c2f11
2 changed files with 16 additions and 9 deletions

View file

@ -123,7 +123,11 @@ export default class CUD extends Component {
if (!isEdit) { if (!isEdit) {
if (data.source === ImportSource.CSV_FILE) { if (data.source === ImportSource.CSV_FILE) {
data.settings.csv = {}; data.settings.csv = {};
// This test needs to be here because this function is also called by the form change detection mechanism
if (this.csvFile && this.csvFile.files && this.csvFile.files.length > 0) {
formData.append('csvFile', this.csvFile.files[0]); formData.append('csvFile', this.csvFile.files[0]);
}
data.settings.csv.delimiter = data.csvDelimiter.trim(); data.settings.csv.delimiter = data.csvDelimiter.trim();
} }
@ -172,6 +176,7 @@ export default class CUD extends Component {
formData.append('entity', JSON.stringify( formData.append('entity', JSON.stringify(
filterData(data, ['name', 'description', 'source', 'settings', 'mapping_type', 'mapping']) filterData(data, ['name', 'description', 'source', 'settings', 'mapping_type', 'mapping'])
)); ));
// TODO - form change detection cannot cope with FormData
return formData; return formData;
} }
@ -271,6 +276,7 @@ export default class CUD extends Component {
if (!isEdit) { if (!isEdit) {
this.navigateTo(`/lists/${this.props.list.id}/imports/${submitResponse}/edit`); this.navigateTo(`/lists/${this.props.list.id}/imports/${submitResponse}/edit`);
} else { } else {
if (runAfterSave) {
try { try {
await axios.post(getUrl(`rest/import-start/${this.props.list.id}/${this.props.entity.id}`)); await axios.post(getUrl(`rest/import-start/${this.props.list.id}/${this.props.entity.id}`));
} catch (err) { } catch (err) {
@ -280,6 +286,7 @@ export default class CUD extends Component {
throw err; throw err;
} }
} }
}
this.navigateToWithFlashMessage(`/lists/${this.props.list.id}/imports/${this.props.entity.id}/status`, 'success', t('importSaved')); this.navigateToWithFlashMessage(`/lists/${this.props.list.id}/imports/${this.props.entity.id}/status`, 'success', t('importSaved'));
} }

View file

@ -47,7 +47,7 @@ export default class List extends Component {
{ data: 2, title: t('description') }, { data: 2, title: t('description') },
{ data: 3, title: t('source'), render: data => this.importSourceLabels[data], sortable: false, searchable: false }, { data: 3, title: t('source'), render: data => this.importSourceLabels[data], sortable: false, searchable: false },
{ data: 4, title: t('status'), render: data => this.importStatusLabels[data], sortable: false, searchable: false }, { data: 4, title: t('status'), render: data => this.importStatusLabels[data], sortable: false, searchable: false },
{ data: 5, title: t('lastRun'), render: data => moment(data).fromNow() }, { data: 5, title: t('lastRun'), render: data => data ? moment(data).fromNow() : t('never') },
{ {
actions: data => { actions: data => {
const actions = []; const actions = [];