diff options
| author | Zog | 2018-03-12 10:42:01 +0100 | 
|---|---|---|
| committer | Alban Peignier | 2018-03-15 13:08:52 +0100 | 
| commit | 410457e1c1cad57ed2109fe8de9d1dc1eecf353f (patch) | |
| tree | 7030d3c58f0697bc0a0f3f4366c9ca612dcb81d9 | |
| parent | 961df1d06016aeff88845f42b377076a6851f6b4 (diff) | |
| download | chouette-core-410457e1c1cad57ed2109fe8de9d1dc1eecf353f.tar.bz2 | |
Refs #6143; Configurable extra headers on VJs editor
6 files changed, 46 insertions, 1 deletions
| diff --git a/app/assets/stylesheets/components/_tables.sass b/app/assets/stylesheets/components/_tables.sass index ef19bd538..ba51f7de7 100644 --- a/app/assets/stylesheets/components/_tables.sass +++ b/app/assets/stylesheets/components/_tables.sass @@ -376,6 +376,9 @@        border-top-color: transparent        > div:not(.btn-group)          min-height: 20px +        white-space: nowrap +        overflow: hidden +        text-overflow: ellipsis      .td > .headlined        &:before diff --git a/app/javascript/vehicle_journeys/components/VehicleJourney.js b/app/javascript/vehicle_journeys/components/VehicleJourney.js index a667bf8aa..73d99d120 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourney.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourney.js @@ -75,6 +75,21 @@ export default class VehicleJourney extends Component {      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 @@ -95,6 +110,11 @@ export default class VehicleJourney extends Component {            <div>{this.props.value.published_journey_name && this.props.value.published_journey_name != I18n.t('undefined') ? this.props.value.published_journey_name : '-'}</div>            <div>{this.props.value.journey_pattern.short_id || '-'}</div>            <div>{this.props.value.company ? this.props.value.company.name : '-'}</div> +          { +            this.props.extraHeaders.map((header, i) => +              <div key={i}>{this.extraHeaderValue(header)}</div> +            ) +          }            { this.hasFeature('purchase_windows') &&              <div>              {purchase_windows.slice(0,3).map((tt, i)=> @@ -222,4 +242,5 @@ VehicleJourney.propTypes = {    vehicleJourneys: PropTypes.object.isRequired,    allTimeTables: PropTypes.array.isRequired,    allPurchaseWindows: PropTypes.array.isRequired, +  extraHeaders: PropTypes.array.isRequired,  } diff --git a/app/javascript/vehicle_journeys/components/VehicleJourneys.js b/app/javascript/vehicle_journeys/components/VehicleJourneys.js index ae38a21af..4b2d8c7a6 100644 --- a/app/javascript/vehicle_journeys/components/VehicleJourneys.js +++ b/app/javascript/vehicle_journeys/components/VehicleJourneys.js @@ -163,6 +163,15 @@ export default class VehicleJourneys extends Component {      )    } +	extraHeaderLabel(header) { +    if(header["type"] == "custom_field"){ +      return this.props.customFields[header["name"]]["name"] +    } +    else{ +      return I18n.attribute_name("vehicle_journey", header) +    } +  } +    render() {      this.previousBreakpoint = undefined      this._allTimeTables = null @@ -231,6 +240,11 @@ export default class VehicleJourneys extends Component {                        )}                      </div>                    } +                  { +                    this.props.extraHeaders.map((header, i) => +                      <div key={i}>{this.extraHeaderLabel(header)}</div> +                    ) +                  }                    <div>                      { detailed_calendars &&                        <a href='#' onClick={this.toggleTimetables} className='detailed-timetables-bt'> @@ -278,6 +292,7 @@ export default class VehicleJourneys extends Component {                        disabled={this.isReturn()}                        allTimeTables={this.allTimeTables()}                        allPurchaseWindows={this.allPurchaseWindows()} +                      extraHeaders={this.props.extraHeaders}                        />                    )}                  </div> @@ -293,6 +308,8 @@ export default class VehicleJourneys extends Component {  VehicleJourneys.propTypes = {    status: PropTypes.object.isRequired,    filters: PropTypes.object.isRequired, +  extraHeaders: PropTypes.array.isRequired, +  customFields: PropTypes.object.isRequired,    stopPointsList: PropTypes.array.isRequired,    onLoadFirstPage: PropTypes.func.isRequired,    onUpdateTime: PropTypes.func.isRequired, diff --git a/app/javascript/vehicle_journeys/containers/VehicleJourneysList.js b/app/javascript/vehicle_journeys/containers/VehicleJourneysList.js index 81d603fd4..f21e2c87e 100644 --- a/app/javascript/vehicle_journeys/containers/VehicleJourneysList.js +++ b/app/javascript/vehicle_journeys/containers/VehicleJourneysList.js @@ -10,7 +10,9 @@ const mapStateToProps = (state) => {      status: state.status,      filters: state.filters,      stopPointsList: state.stopPointsList, -    returnStopPointsList: state.returnStopPointsList +    returnStopPointsList: state.returnStopPointsList, +    extraHeaders: window.extra_headers, +    customFields: window.custom_fields,    }  } diff --git a/app/views/vehicle_journeys/index.html.slim b/app/views/vehicle_journeys/index.html.slim index d53d8b50c..5606bc055 100644 --- a/app/views/vehicle_journeys/index.html.slim +++ b/app/views/vehicle_journeys/index.html.slim @@ -29,6 +29,7 @@    | window.features = #{raw @features};    | window.all_missions = #{(@all_missions.to_json).html_safe};    | window.custom_fields = #{(@custom_fields.to_json).html_safe}; +  | window.extra_headers = #{Rails.application.config.vehicle_journeys_extra_headers.to_json.html_safe};    // | window.I18n = #{(I18n.backend.send(:translations).to_json).html_safe};  - if has_feature?(:vehicle_journeys_return_route) diff --git a/config/application.rb b/config/application.rb index 8da6a7428..fabea41de 100644 --- a/config/application.rb +++ b/config/application.rb @@ -40,6 +40,7 @@ module ChouetteIhm      )      config.development_toolbar = false +    config.vehicle_journeys_extra_headers = []      unless Rails.env.production?          # Work around sprockets+teaspoon mismatch: | 
