aboutsummaryrefslogtreecommitdiffstats
path: root/app/javascript/helpers
diff options
context:
space:
mode:
authorAlban Peignier2018-01-10 16:11:58 +0100
committerGitHub2018-01-10 16:11:58 +0100
commit71614a19f62ed3f9ca3068e149dcd60471bef27d (patch)
tree482a2acd38bc26cbf8ff526251f8559728ef5ecb /app/javascript/helpers
parentc2ad59547e94ac72227bfc1af79186d460eb8671 (diff)
parent18d6fa534a33cf9d3b3d8a7ab680851b2a0afff4 (diff)
downloadchouette-core-71614a19f62ed3f9ca3068e149dcd60471bef27d.tar.bz2
Merge pull request #194 from af83/5156-handle-long-distance-routes
Handle long distance routes. Refs #5156
Diffstat (limited to 'app/javascript/helpers')
-rw-r--r--app/javascript/helpers/stop_area_header_manager.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/app/javascript/helpers/stop_area_header_manager.js b/app/javascript/helpers/stop_area_header_manager.js
new file mode 100644
index 000000000..54d957be9
--- /dev/null
+++ b/app/javascript/helpers/stop_area_header_manager.js
@@ -0,0 +1,42 @@
+import React, { Component } from 'react'
+
+export default class StopAreaHeaderManager {
+ constructor(ids_list, stopPointsList, features) {
+ this.ids_list = ids_list
+ this.stopPointsList = stopPointsList
+ this.features = features
+ }
+
+ hasFeature(key) {
+ return this.features[key]
+ }
+
+ stopPointHeader(object_id) {
+ let index = this.ids_list.indexOf(object_id)
+ let sp = this.stopPointsList[index]
+ let showHeadline = this.showHeader(object_id)
+ return (
+ <div
+ className={(showHeadline) ? 'headlined' : ''}
+ data-headline={showHeadline}
+ title={sp.city_name + ' (' + sp.zip_code +')'}
+ >
+ <span><span>{sp.name}</span></span>
+ </div>
+ )
+ }
+
+ showHeader(object_id) {
+ let showHeadline = false
+ let headline = ""
+ let attribute_to_check = this.hasFeature('long_distance_routes') ? "country_code" : "city_name"
+ let index = this.ids_list.indexOf(object_id)
+ let sp = this.stopPointsList[index]
+ let previousBreakpoint = this.stopPointsList[index - 1]
+ if(index == 0 || (sp[attribute_to_check] != previousBreakpoint[attribute_to_check])){
+ showHeadline = true
+ headline = this.hasFeature('long_distance_routes') ? sp.country_name : sp.city_name
+ }
+ return showHeadline ? headline : ""
+ }
+}