import React, { Component } from 'react' import PropTypes from 'prop-types' import actions from '../../actions' import MissionSelect2 from './select2s/MissionSelect2' import CompanySelect2 from './select2s/CompanySelect2' import CustomFieldsInputs from '../../../helpers/CustomFieldsInputs' export default class CreateModal extends Component { constructor(props) { super(props) this.custom_fields = _.assign({}, this.props.custom_fields) _.map(this.custom_fields, (cf, k)=>{ if(cf.options && cf.options.default){ this.custom_fields[k]["value"] = cf.options.default } }) } handleSubmit() { if(!this.props.modal.modalProps.selectedJPModal){ let field = $('#NewVehicleJourneyModal').find(".vjCreateSelectJP") field.parent().parent().addClass('has-error') field.parent().children('.help-block').remove() field.parent().append("" + I18n.t("simple_form.required.text") + "") return } if (actions.validateFields(...this.refs, $('.vjCreateSelectJP')[0])) { this.props.onAddVehicleJourney(_.assign({}, this.refs, {custom_fields: this.custom_fields}), this.props.modal.modalProps.selectedJPModal, this.props.stopPointsList, this.props.modal.modalProps.vehicleJourney && this.props.modal.modalProps.vehicleJourney.company) this.props.onModalClose() $('#NewVehicleJourneyModal').modal('hide') } } render() { if(this.props.status.isFetching == true) { return false } if(this.props.status.fetchSuccess == true) { return (
  • {I18n.t('vehicle_journeys.actions.new')}

    ×
    {(this.props.modal.type == 'create') && (
    actions.resetValidation(e.currentTarget)} />
    this.props.onSelect2Company(e)} onUnselect2Company = {() => this.props.onUnselect2Company()} />
    actions.resetValidation(e.currentTarget)} />
    this.custom_fields[code]["value"] = value} disabled={false} /> { this.props.modal.modalProps.selectedJPModal && this.props.modal.modalProps.selectedJPModal.full_schedule &&
    actions.resetValidation(e.currentTarget)} /> actions.resetValidation(e.currentTarget)} />
    }
    )}
  • ) } else { return false } } } CreateModal.propTypes = { index: PropTypes.number, modal: PropTypes.object.isRequired, status: PropTypes.object.isRequired, stopPointsList: PropTypes.array.isRequired, onOpenCreateModal: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired, onAddVehicleJourney: PropTypes.func.isRequired, onSelect2JourneyPattern: PropTypes.func.isRequired, disabled: PropTypes.bool.isRequired, missions: PropTypes.array.isRequired }