import React, { Component } from 'react' import PropTypes from 'prop-types' import _ from 'lodash' import JourneyPattern from './JourneyPattern' import StopAreaHeaderManager from '../../helpers/stop_area_header_manager' export default class JourneyPatterns extends Component { constructor(props){ super(props) this.headerManager = new StopAreaHeaderManager( _.map(this.props.stopPointsList, (sp, i)=>{return sp.stop_area_object_id + "-" + i}), this.props.stopPointsList, this.props.status.features ) } componentDidMount() { this.props.onLoadFirstPage() } componentDidUpdate(prevProps, prevState) { if(this.props.status.isFetching == false){ $('.table-2entries').each(function() { var refH = [] var refCol = [] $(this).find('.t2e-head').children('div').each(function() { var h = this.getBoundingClientRect().height; refH.push(h) }); var i = 0 $(this).find('.t2e-item').children('div').each(function() { var h = this.getBoundingClientRect().height; if(refCol.length < refH.length){ refCol.push(h) } else { if(h > refCol[i]) { refCol[i] = h } } if(i == (refH.length - 1)){ i = 0 } else { i++ } }); for(var n = 0; n < refH.length; n++) { if(refCol[n] < refH[n]) { refCol[n] = refH[n] } } $(this).find('.th').css('height', refCol[0]); for(var nth = 1; nth < refH.length; nth++) { $(this).find('.td:nth-child('+ (nth + 1) +')').css('height', refCol[nth]); } }); } } showHeader(object_id) { return this.headerManager.showHeader(object_id) } hasFeature(key) { return this.props.status.features[key] } render() { this.previousCity = undefined if(this.props.status.isFetching == true) { return (