diff --git a/importApp/src/components/FieldInput.js b/importApp/src/components/FieldInput.js
index 4273df85..072a7424 100644
--- a/importApp/src/components/FieldInput.js
+++ b/importApp/src/components/FieldInput.js
@@ -150,7 +150,7 @@ class FieldInput extends React.Component {
renderField() {
- const {fieldValue, foreignKeys, referenceTables, showNewReference, newReference, isNonchangable, suggestedOptions} = this.props;
+ const {fieldValue, foreignKeys, referenceTables, showNewReference, newReference, isNonchangable, isValidationField, suggestedOptions} = this.props;
const {fieldSchema, fieldValid, value, suggestions} = this.state;
// Autosuggest will pass through all these props to the input.
@@ -205,7 +205,7 @@ class FieldInput extends React.Component {
{fieldValue}
}
{
- !this.state.value &&
+ (!this.state.value || isValidationField) &&
}
diff --git a/importApp/src/components/ReferenceResourceForm.js b/importApp/src/components/ReferenceResourceForm.js
index a7355043..818b0256 100644
--- a/importApp/src/components/ReferenceResourceForm.js
+++ b/importApp/src/components/ReferenceResourceForm.js
@@ -25,7 +25,7 @@ class ReferenceResourceForm extends React.Component {
}
getStateFromProps = () => {
- const {resourceDescriptor, originalValues} = this.props;
+ const {resourceDescriptor, originalValues, prefixedValues} = this.props;
const {schema} = resourceDescriptor;
const newResource = schema.fields.reduce((res, field) => {
let value = '';
@@ -38,6 +38,10 @@ class ReferenceResourceForm extends React.Component {
value = originalValues.find((item) => item.referenceField=== field.name).value;
valid = true;
}
+ if (prefixedValues && prefixedValues[field.name]) {
+ value = prefixedValues[field.name];
+ valid = true
+ }
return {
...res,
[field.name]: {
@@ -111,6 +115,7 @@ class ReferenceResourceForm extends React.Component {
newReference: null,
referenceMap: null,
isRICentityGroup: false,
+ prefixedValues: null,
newResource: {
...this.state.newResource,
[field]: {
@@ -182,7 +187,7 @@ class ReferenceResourceForm extends React.Component {
}
render() {
- const {descriptor, resourceDescriptor, referenceTables, originalValues} = this.props;
+ const {descriptor, resourceDescriptor, referenceTables, originalValues, prefixedValues} = this.props;
const {schema} = resourceDescriptor;
const fieldsInvalid = values(this.state.newResource).filter((field) => field.fieldValid && !field.fieldValid.valid);
@@ -211,12 +216,16 @@ class ReferenceResourceForm extends React.Component {
exchange_rates: referenceTables['exchange_rates']
};
let table;
+ const prefixedValues = {
+ "modified_currency": this.state.newResource['modified_currency'].value
+ }
try {
table = await Table.load(source, {schema});
const rows = await table.read({forceCast: true, relations});
const errors = rows.filter((row) => row.errors);
if (errors.length) {
this.setState({
+ prefixedValues,
resourceValid: {
valid: false,
message: errors[0].errors[0].errors[0].message
@@ -230,6 +239,7 @@ class ReferenceResourceForm extends React.Component {
}
} catch (error) {
this.setState({
+ prefixedValues,
resourceValid: {
valid: false,
message: error.message || 'validation fail'
@@ -255,12 +265,13 @@ class ReferenceResourceForm extends React.Component {
return (
item.field === 'year')}
resourceDescriptor={getReferenceDescriptor()}
referenceTables={referenceTables}
+ prefixedValues={this.state.prefixedValues}
onSelectGroup={this.handleSelectGroup}
onCancel={this.handleHideNew}
onAddNew={this.handleAddNewReference} />