|
|
@ -19,23 +19,6 @@ class FormFactory extends Component { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
componentWillMount() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
submit = (values) => { |
|
|
|
submit = (values) => { |
|
|
|
if(values.id){ |
|
|
|
if(values.id){ |
|
|
|
this.props.updateFactory(values.id, values); |
|
|
|
this.props.updateFactory(values.id, values); |
|
|
@ -68,7 +51,7 @@ class FormFactory extends Component { |
|
|
|
component={TreeSelectField} |
|
|
|
component={TreeSelectField} |
|
|
|
placeholder="Батьківська категорія" |
|
|
|
placeholder="Батьківська категорія" |
|
|
|
label="Батьківська категорія" |
|
|
|
label="Батьківська категорія" |
|
|
|
tree={genTree(_.cloneDeep(factory))} |
|
|
|
tree={genTree(_.cloneDeep(factory), undefined, undefined, 'parent_factory')} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<Field |
|
|
|
<Field |
|
|
|
name='director' |
|
|
|
name='director' |
|
|
@ -96,13 +79,21 @@ FormFactory = reduxForm({ |
|
|
|
{name: 'name', rules: [{name: 'required', message: 'Заповнити обовязково'}]}, |
|
|
|
{name: 'name', rules: [{name: 'required', message: 'Заповнити обовязково'}]}, |
|
|
|
// {name: 'password', rules: [{name: 'required', message: 'Заповнити обовязково'}]}, |
|
|
|
// {name: 'password', rules: [{name: 'required', message: 'Заповнити обовязково'}]}, |
|
|
|
] |
|
|
|
] |
|
|
|
return validationFields(fields, values) |
|
|
|
|
|
|
|
|
|
|
|
let error = validationFields(fields, values); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(values.id == values.parent_factory && values.parent_factory){ |
|
|
|
|
|
|
|
error.parent_factory = 'Невірна батьківська категорія' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return error; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
})(FormFactory); |
|
|
|
})(FormFactory); |
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => ({ |
|
|
|
const mapStateToProps = (state, ownProps) => ({ |
|
|
|
factory: state.factory.data, |
|
|
|
factory: state.factory.data, |
|
|
|
initialValues: Object.assign({}, state.factory.item_factory, {parent_factory: state.factory.active_factory}) , |
|
|
|
initialValues: Object.assign({}, state.factory.item_factory) , |
|
|
|
users: state.factory.users, |
|
|
|
users: state.factory.users, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|