aboutsummaryrefslogtreecommitdiffstats
path: root/app/javascript/vehicle_journeys/components
diff options
context:
space:
mode:
authorZog2018-02-01 10:34:40 +0100
committerZog2018-02-01 10:34:40 +0100
commitd114d549f7bc8a772803175dee9a665266d8ed04 (patch)
tree228fa0008b6938d4d7682896df1d9578abdce872 /app/javascript/vehicle_journeys/components
parent90f54f0acfe65ff276a229239809ce0e9fddf0b0 (diff)
downloadchouette-core-d114d549f7bc8a772803175dee9a665266d8ed04.tar.bz2
Refs #5798 @3h; Show return journeys on the journeys' editor.
Diffstat (limited to 'app/javascript/vehicle_journeys/components')
-rw-r--r--app/javascript/vehicle_journeys/components/App.js1
-rw-r--r--app/javascript/vehicle_journeys/components/VehicleJourney.js6
-rw-r--r--app/javascript/vehicle_journeys/components/VehicleJourneys.js41
-rw-r--r--app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js8
4 files changed, 43 insertions, 13 deletions
diff --git a/app/javascript/vehicle_journeys/components/App.js b/app/javascript/vehicle_journeys/components/App.js
index 44559c7c6..5ac284438 100644
--- a/app/javascript/vehicle_journeys/components/App.js
+++ b/app/javascript/vehicle_journeys/components/App.js
@@ -22,6 +22,7 @@ export default function App() {
<Filters />
<VehicleJourneysList />
+ {window.returnRouteUrl && <VehicleJourneysList routeUrl={window.returnRouteUrl}/>}
<div className='row'>
<div className='col-lg-12 text-right'>
diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js
index 2b5783dda..e7d4b5b30 100644
--- a/app/javascript/vehicle_journeys/components/VehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js
@@ -1,6 +1,7 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import actions from '../actions'
+import EditVehicleJourney from '../containers/tools/EditVehicleJourney'
export default class VehicleJourney extends Component {
constructor(props) {
@@ -80,7 +81,7 @@ export default class VehicleJourney extends Component {
{purchase_windows.length > 3 && <span className='vj_tt'> + {purchase_windows.length - 3}</span>}
</div>
}
- <div className={(this.props.value.deletable ? 'disabled ' : '') + 'checkbox'}>
+ {!this.props.disabled && <div className={(this.props.value.deletable ? 'disabled ' : '') + 'checkbox'}>
<input
id={this.props.index}
name={this.props.index}
@@ -91,7 +92,8 @@ export default class VehicleJourney extends Component {
checked={this.props.value.selected}
></input>
<label htmlFor={this.props.index}></label>
- </div>
+ </div>}
+ {this.props.disabled && <EditVehicleJourney disabled={false} vehicleJourney={this.props.value} />}
</div>
{this.props.value.vehicle_journey_at_stops.map((vj, i) =>
<div key={i} className='td text-center'>
diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js
index 256ca81f9..ae852b35a 100644
--- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js
+++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js
@@ -8,14 +8,36 @@ export default class VehicleJourneys extends Component {
constructor(props){
super(props)
this.headerManager = new StopAreaHeaderManager(
- _.map(this.props.stopPointsList, (sp)=>{return sp.object_id}),
- this.props.stopPointsList,
+ _.map(this.stopPoints(), (sp)=>{return sp.object_id}),
+ this.stopPoints(),
this.props.filters.features
)
}
+ isReturn() {
+ return this.props.routeUrl != undefined
+ }
+
+ vehicleJourneysList() {
+ if(this.isReturn()){
+ return this.props.returnVehicleJourneys
+ }
+ else{
+ return this.props.vehicleJourneys
+ }
+ }
+
+ stopPoints() {
+ if(this.isReturn()){
+ return this.props.returnStopPointsList
+ }
+ else{
+ return this.props.stopPointsList
+ }
+ }
+
componentDidMount() {
- this.props.onLoadFirstPage(this.props.filters)
+ this.props.onLoadFirstPage(this.props.filters, this.props.routeUrl)
}
hasFeature(key) {
@@ -89,10 +111,10 @@ export default class VehicleJourneys extends Component {
</div>
)}
- { this.props.vehicleJourneys.errors && this.props.vehicleJourneys.errors.length && _.some(this.props.vehicleJourneys, 'errors') && (
+ { this.vehicleJourneysList().errors && this.vehicleJourneysList().errors.length && _.some(this.vehicleJourneysList(), 'errors') && (
<div className="alert alert-danger mt-sm">
<strong>Erreur : </strong>
- {this.props.vehicleJourneys.map((vj, index) =>
+ {this.vehicleJourneysList().map((vj, index) =>
vj.errors && vj.errors.map((err, i) => {
return (
<ul key={i}>
@@ -104,7 +126,7 @@ export default class VehicleJourneys extends Component {
</div>
)}
- <div className={'table table-2entries mt-sm mb-sm' + ((this.props.vehicleJourneys.length > 0) ? '' : ' no_result')}>
+ <div className={'table table-2entries mt-sm mb-sm' + ((this.vehicleJourneysList().length > 0) ? '' : ' no_result')}>
<div className='t2e-head w20'>
<div className='th'>
<div className='strong mb-xs'>ID course</div>
@@ -114,7 +136,7 @@ export default class VehicleJourneys extends Component {
<div>Calendriers</div>
{ this.hasFeature('purchase_windows') && <div>Calendriers Commerciaux</div> }
</div>
- {this.props.stopPointsList.map((sp, i) =>{
+ {this.stopPoints().map((sp, i) =>{
return (
<div key={i} className='td'>
{this.headerManager.stopPointHeader(sp.object_id)}
@@ -125,17 +147,18 @@ export default class VehicleJourneys extends Component {
<div className='t2e-item-list w80'>
<div>
- {this.props.vehicleJourneys.map((vj, index) =>
+ {this.vehicleJourneysList().map((vj, index) =>
<VehicleJourney
value={vj}
key={index}
index={index}
- editMode={this.props.editMode}
+ editMode={this.isReturn() ? false : this.props.editMode}
filters={this.props.filters}
features={this.props.features}
onUpdateTime={this.props.onUpdateTime}
onSelectVehicleJourney={this.props.onSelectVehicleJourney}
vehicleJourneys={this}
+ disabled={this.isReturn()}
/>
)}
</div>
diff --git a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
index 2893422f8..f814c0459 100644
--- a/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
+++ b/app/javascript/vehicle_journeys/components/tools/EditVehicleJourney.js
@@ -23,6 +23,10 @@ export default class EditVehicleJourney extends Component {
}
}
+ getSelected() {
+ return this.props.vehicleJourney ? [this.props.vehicleJourney] : actions.getSelected(this.props.vehicleJourneys)
+ }
+
render() {
if(this.props.status.isFetching == true) {
return false
@@ -35,10 +39,10 @@ export default class EditVehicleJourney extends Component {
<li className='st_action'>
<button
type='button'
- disabled={(actions.getSelected(this.props.vehicleJourneys).length != 1 || this.props.disabled)}
+ disabled={(this.getSelected().length != 1 || this.props.disabled)}
data-toggle='modal'
data-target='#EditVehicleJourneyModal'
- onClick={() => this.props.onOpenEditModal(actions.getSelected(this.props.vehicleJourneys)[0])}
+ onClick={() => this.props.onOpenEditModal(this.getSelected()[0])}
>
<span className='fa fa-info'></span>
</button>