aboutsummaryrefslogtreecommitdiffstats
path: root/app/javascript/vehicle_journeys/components
diff options
context:
space:
mode:
authorZog2018-01-11 14:37:14 +0100
committerZog2018-01-11 14:37:14 +0100
commitcb0564d4d7d35c8a43e166b68d8c7dc94341fc9d (patch)
treea06beac9be2f17a49f572a844b8aa6d5171101e7 /app/javascript/vehicle_journeys/components
parent8b3702a4c7f873e01e543034841de5dbecc30c06 (diff)
downloadchouette-core-cb0564d4d7d35c8a43e166b68d8c7dc94341fc9d.tar.bz2
Refs #5551 @1.5h; Implement Custom fields edition
RBD: implement the same in the creation modal
Diffstat (limited to 'app/javascript/vehicle_journeys/components')
-rw-r--r--app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
index 08d74baba..b46857d19 100644
--- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
@@ -2,10 +2,12 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types'
import actions from '../../actions'
import CompanySelect2 from './select2s/CompanySelect2'
+import Select2 from 'react-select2-wrapper'
export default class EditVehicleJourney extends Component {
constructor(props) {
super(props)
+ this.custom_fields = {}
}
handleSubmit() {
@@ -15,8 +17,8 @@ export default class EditVehicleJourney extends Component {
company = this.props.modal.modalProps.selectedCompany
} else if (typeof this.props.modal.modalProps.vehicleJourney.company === "object") {
company = this.props.modal.modalProps.vehicleJourney.company
- }
- this.props.onEditVehicleJourney(this.refs, company)
+ }
+ this.props.onEditVehicleJourney(_.assign({}, this.refs, {custom_fields: this.custom_fields}), company)
this.props.onModalClose()
$('#EditVehicleJourneyModal').modal('hide')
}
@@ -140,6 +142,22 @@ export default class EditVehicleJourney extends Component {
defaultValue={this.props.modal.modalProps.vehicleJourney.checksum}
/>
</div>
+ {_.map(this.props.modal.modalProps.vehicleJourney.custom_fields, (cf, code) =>
+ <div className='form-group' key={code}>
+ <label className='control-label'>{cf.name}</label>
+ <Select2
+ data={_.map(cf.options.list_values, (v, k) => {
+ return {id: k, text: v}
+ })}
+ ref={'custom_fields.' + code}
+ className='form-control'
+ value={cf.value}
+ disabled={!this.props.editMode}
+ options={{theme: 'bootstrap'}}
+ onSelect={(e) => this.custom_fields[code] = e.params.data.id }
+ />
+ </div>
+ )}
</div>
{