import React, { Component } from 'react' import PropTypes from 'prop-types' import actions from '../actions' import EditVehicleJourney from '../containers/tools/EditVehicleJourney' import VehicleJourneyInfoButton from '../containers/tools/VehicleJourneyInfoButton' export default class VehicleJourney extends Component { constructor(props) { super(props) this.previousCity = undefined } journey_length() { return this.props.value.journey_pattern.journey_length + "km" } cityNameChecker(sp) { return this.props.vehicleJourneys.showHeader(sp.stop_point_objectid) } hasFeature(key) { return this.props.filters.features[key] } timeTableURL(tt) { let refURL = window.location.pathname.split('/', 3).join('/') let ttURL = refURL + '/time_tables/' + tt.id return ( ) } purchaseWindowURL(tt) { let refURL = window.location.pathname.split('/', 3).join('/') let ttURL = refURL + '/purchase_windows/' + tt.id return ( ) } columnHasDelta() { let a = [] this.props.value.vehicle_journey_at_stops.map((vj, i) => { a.push(vj.delta) }) let b = a.reduce((p, c) => p+c, 0) if(b > 0) { return true } } displayDelta(delta) { if(delta > 99){ return "+" } return delta } hasTimeTable(time_tables, tt) { let found = false time_tables.map((t, index) => { if(t.id == tt.id){ found = true return } }) return found } hasPurchaseWindow(purchase_windows, window) { return this.hasTimeTable(purchase_windows, window) } isDisabled(bool1, bool2) { return (bool1 || bool2) } extraHeaderValue(header) { if(header.type == "custom_field"){ let field = this.props.value.custom_fields[header["name"]] if(field.field_type == "list"){ return field.options.list_values[field.value] } else{ return field.value } } else{ return this.props.value[header["name"]] } } render() { this.previousCity = undefined let detailed_calendars = this.hasFeature('detailed_calendars') && !this.disabled let detailed_calendars_shown = $('.detailed-timetables-bt').hasClass('active') let detailed_purchase_windows = this.hasFeature('detailed_purchase_windows') && !this.disabled let detailed_purchase_windows_shown = $('.detailed-purchase-windows-bt').hasClass('active') let {time_tables, purchase_windows} = this.props.value return (