Some fixes
This commit is contained in:
parent
640d3c2f11
commit
1270ca71f8
13 changed files with 68 additions and 73 deletions
|
@ -987,7 +987,7 @@ const withForm = createComponentMixin([], [], (TargetClass, InnerClass) => {
|
|||
let data = formStateData.map(attr => attr.get('value')).toJS();
|
||||
|
||||
if (self.submitFormValuesMutator) {
|
||||
const newData = self.submitFormValuesMutator(data);
|
||||
const newData = self.submitFormValuesMutator(data, false);
|
||||
if (newData !== undefined) {
|
||||
data = newData;
|
||||
}
|
||||
|
@ -1169,7 +1169,7 @@ const withForm = createComponentMixin([], [], (TargetClass, InnerClass) => {
|
|||
let data = this.getFormValues();
|
||||
|
||||
if (this.submitFormValuesMutator) {
|
||||
const newData = this.submitFormValuesMutator(data);
|
||||
const newData = this.submitFormValuesMutator(data, true);
|
||||
if (newData !== undefined) {
|
||||
data = newData;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,10 @@ export default class CUD extends Component {
|
|||
data.to_name = null;
|
||||
}
|
||||
|
||||
return filterData(data, ['name', 'description', 'default_form', 'public_subscribe', 'unsubscription_mode', 'contact_email', 'homepage', 'namespace', 'to_name', 'listunsubscribe_disabled', 'send_configuration']);
|
||||
return filterData(data, ['name', 'description', 'default_form', 'public_subscribe', 'unsubscription_mode',
|
||||
'contact_email', 'homepage', 'namespace', 'to_name', 'listunsubscribe_disabled', 'send_configuration',
|
||||
'fieldWizard'
|
||||
]);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
@ -78,7 +81,7 @@ export default class CUD extends Component {
|
|||
name: '',
|
||||
description: '',
|
||||
form: 'default',
|
||||
default_form: null,
|
||||
default_form: 'default',
|
||||
public_subscribe: true,
|
||||
contact_email: '',
|
||||
homepage: '',
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
import {withAsyncErrorHandler, withErrorHandling} from '../../lib/error-handling';
|
||||
import {DeleteModalDialog} from "../../lib/modals";
|
||||
import {getImportLabels} from './helpers';
|
||||
import {ImportSource, inProgress, MappingType, prepInProgress} from '../../../../shared/imports';
|
||||
import {ImportSource, inProgress, MappingType, prepInProgress, prepFinished} from '../../../../shared/imports';
|
||||
import axios from "../../lib/axios";
|
||||
import {getUrl} from "../../lib/urls";
|
||||
import listStyles from "../styles.scss";
|
||||
|
@ -113,21 +113,31 @@ export default class CUD extends Component {
|
|||
data.mapping_fields_email_column = emailMapping.column || '';
|
||||
}
|
||||
|
||||
submitFormValuesMutator(data) {
|
||||
submitFormValuesMutator(data, isSubmit) {
|
||||
const isEdit = !!this.props.entity;
|
||||
|
||||
data.source = Number.parseInt(data.source);
|
||||
data.settings = {};
|
||||
|
||||
const formData = new FormData();
|
||||
let formData, csvFileSelected = false;
|
||||
if (isSubmit) {
|
||||
formData = new FormData();
|
||||
|
||||
}
|
||||
|
||||
if (!isEdit) {
|
||||
if (data.source === ImportSource.CSV_FILE) {
|
||||
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]);
|
||||
if (isSubmit) {
|
||||
formData.append('csvFile', this.csvFile.files[0]);
|
||||
} else {
|
||||
csvFileSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
data.settings.csv.delimiter = data.csvDelimiter.trim();
|
||||
}
|
||||
|
||||
|
@ -173,12 +183,21 @@ export default class CUD extends Component {
|
|||
data.mapping = mapping;
|
||||
}
|
||||
|
||||
formData.append('entity', JSON.stringify(
|
||||
filterData(data, ['name', 'description', 'source', 'settings', 'mapping_type', 'mapping'])
|
||||
));
|
||||
// TODO - form change detection cannot cope with FormData
|
||||
if (isSubmit) {
|
||||
formData.append('entity', JSON.stringify(
|
||||
filterData(data, ['name', 'description', 'source', 'settings', 'mapping_type', 'mapping'])
|
||||
));
|
||||
|
||||
return formData;
|
||||
return formData;
|
||||
|
||||
} else {
|
||||
const filteredData = filterData(data, ['name', 'description', 'source', 'settings', 'mapping_type', 'mapping']);
|
||||
if (csvFileSelected) {
|
||||
filteredData.csvFileSelected = true;
|
||||
}
|
||||
|
||||
return filteredData;
|
||||
}
|
||||
}
|
||||
|
||||
initFromEntity(entity) {
|
||||
|
@ -406,8 +425,10 @@ export default class CUD extends Component {
|
|||
if (!isEdit) {
|
||||
saveButtons.push(<Button key="default" type="submit" className="btn-primary" icon="check" label={t('saveAndEditSettings')}/>);
|
||||
} else {
|
||||
saveButtons.push(<Button key="default" type="submit" className="btn-primary" icon="check" label={t('save')}/>);
|
||||
saveButtons.push(<Button key="saveAndRun" className="btn-primary" icon="check" label={t('saveAndRun')} onClickAsync={async () => await this.save(true)}/>);
|
||||
if (prepFinished(status)) {
|
||||
saveButtons.push(<Button key="default" type="submit" className="btn-primary" icon="check" label={t('save')}/>);
|
||||
saveButtons.push(<Button key="saveAndRun" className="btn-primary" icon="check" label={t('saveAndRun')} onClickAsync={async () => await this.save(true)}/>);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue