aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert2017-04-19 13:24:41 +0200
committerRobert2017-04-19 13:24:41 +0200
commitc41b0355438280f04dfad723527c9db38e325c36 (patch)
tree62c16537f70f5aab355e7c10d6ec017bfb797632
parentf18d0a349eeec0822c02b08bbee276398aa40975 (diff)
parent59c35cb1d787d9c3a2eb76da0a22fcbeaa5fa003 (diff)
downloadchouette-core-c41b0355438280f04dfad723527c9db38e325c36.tar.bz2
Merge branch 'master' of github.com:af83/stif-boiv
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/actions/index.js46
-rw-r--r--app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js4
-rw-r--r--app/models/chouette/routing_constraint_zone.rb8
-rw-r--r--app/views/routing_constraint_zones/index.html.slim2
-rw-r--r--app/views/stop_areas/show.html.slim2
-rw-r--r--config/locales/routing_constraint_zones.en.yml4
-rw-r--r--config/locales/routing_constraint_zones.fr.yml3
7 files changed, 46 insertions, 23 deletions
diff --git a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js
index f17a20e7d..1a6b7d197 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js
@@ -69,31 +69,39 @@ const actions = {
return monthList[date.getMonth()]
},
- updateSynthesis: (state) => {
+ updateSynthesis: (state, daytypes) => {
let periods = state.time_table_periods
- let isInPeriod = function(data){
+ let isInPeriod = function(d){
let currentMonth = state.current_periode_range.split('-')
- let currentDate = new Date(currentMonth[0] + '-' + currentMonth[1] + '-' + data.mday)
+ let twodigitsDay = d.mday < 10 ? ('0' + d.mday) : d.mday
+ let currentDate = new Date(currentMonth[0] + '-' + currentMonth[1] + '-' + twodigitsDay)
- // Exception wins anyway
- if(data.excluded_date) {
- return false
- } else if(data.include_date) {
- return true
- } else {
- // We compare periods & currentdate, to determine if it is included or not
- let testDate = false
- periods.map((p, i) => {
- let begin = new Date(p.period_start)
- let end = new Date(p.period_end)
+ // We compare periods & currentDate, to determine if it is included or not
+ let testDate = false
+ periods.map((p, i) => {
+ let begin = new Date(p.period_start)
+ let end = new Date(p.period_end)
+ if(testDate === false){
if(currentDate >= begin && currentDate <= end) {
- testDate = true
+ if(d.excluded_date) {
+ testDate = false
+ } else if(daytypes[d.wday] === false) {
+ testDate = false
+ } else {
+ testDate = true
+ }
+ } else {
+ if(d.include_date) {
+ testDate = true
+ } else {
+ testDate = false
+ }
}
- })
- return testDate
- }
+ }
+ })
+ return testDate
}
let improvedCM = state.current_month.map((d, i) => {
@@ -114,7 +122,7 @@ const actions = {
},
fetchTimeTables: (dispatch, nextPage) => {
let urlJSON = window.location.pathname.split('/', 5).join('/')
- console.log(nextPage)
+ // console.log(nextPage)
if(nextPage) {
urlJSON += "/month.json?date=" + nextPage
}else{
diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
index b2e5ad0be..1c492859f 100644
--- a/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
+++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js
@@ -10,12 +10,12 @@ const timetable = (state = {}, action) => {
periode_range: action.json.periode_range,
time_table_periods: action.json.time_table_periods
})
- return _.assign({}, fetchedState, {current_month: actions.updateSynthesis(fetchedState)})
+ return _.assign({}, fetchedState, {current_month: actions.updateSynthesis(fetchedState, actions.strToArrayDayTypes(action.json.day_types))})
case 'RECEIVE_MONTH':
let newState = _.assign({}, state, {
current_month: action.json.days
})
- return _.assign({}, newState, {current_month: actions.updateSynthesis(newState)})
+ return _.assign({}, newState, {current_month: actions.updateSynthesis(newState, actions.strToArrayDayTypes(action.json.day_types))})
case 'GO_TO_PREVIOUS_PAGE':
case 'GO_TO_NEXT_PAGE':
let nextPage = action.nextPage ? 1 : -1
diff --git a/app/models/chouette/routing_constraint_zone.rb b/app/models/chouette/routing_constraint_zone.rb
index a2e5a06cc..6a8847e4d 100644
--- a/app/models/chouette/routing_constraint_zone.rb
+++ b/app/models/chouette/routing_constraint_zone.rb
@@ -13,4 +13,12 @@ class Chouette::RoutingConstraintZone < Chouette::TridentActiveRecord
def not_all_stop_points_selected
errors.add(:stop_point_ids, I18n.t('activerecord.errors.models.routing_constraint_zone.attributes.stop_points.all_stop_points_selected')) if stop_points.length == route.stop_points.length
end
+
+ def stop_points_count
+ stop_points.count
+ end
+
+ def route_name
+ route.name
+ end
end
diff --git a/app/views/routing_constraint_zones/index.html.slim b/app/views/routing_constraint_zones/index.html.slim
index e8da0f974..620b0f7db 100644
--- a/app/views/routing_constraint_zones/index.html.slim
+++ b/app/views/routing_constraint_zones/index.html.slim
@@ -5,7 +5,7 @@
- if @routing_constraint_zones.any?
= table_builder @routing_constraint_zones,
- { :name => 'name' },
+ { objectid: 'objectid', name: 'name', route: 'route_name', stop_points_count: 'stop_points_count' },
[:show, :edit, :delete],
[],
'table table-bordered'
diff --git a/app/views/stop_areas/show.html.slim b/app/views/stop_areas/show.html.slim
index 9affba08e..58a2dbde3 100644
--- a/app/views/stop_areas/show.html.slim
+++ b/app/views/stop_areas/show.html.slim
@@ -22,7 +22,7 @@
= definition_list t('metadatas'),
{ @stop_area.human_attribute_name(:stop_area_type) => t("area_types.label.#{@stop_area.stop_area_type}"),
@stop_area.human_attribute_name(:registration_number) => @stop_area.registration_number,
- 'Code Reflex' => @stop_area.try(:objectid),
+ 'Code Reflex' => @stop_area.user_objectid,
'Coordonnées' => geo_data(@stop_area, @stop_area_referential),
@stop_area.human_attribute_name(:zip_code) => @stop_area.zip_code,
@stop_area.human_attribute_name(:city_name) => @stop_area.city_name,
diff --git a/config/locales/routing_constraint_zones.en.yml b/config/locales/routing_constraint_zones.en.yml
index 6599989e8..2d4412dba 100644
--- a/config/locales/routing_constraint_zones.en.yml
+++ b/config/locales/routing_constraint_zones.en.yml
@@ -9,6 +9,9 @@ en:
line: Line
created_at: Created at
updated_at: Updated at
+ objectid: Object ID
+ stop_points_count: Number of stop points
+ route: Route
errors:
models:
routing_constraint_zone:
@@ -16,6 +19,7 @@ en:
stop_points:
not_enough_stop_points: 'You should specify at least 2 stop points.'
stop_points_not_from_route: 'Stop point does not belong to the Route of this Routing constraint zone.'
+ all_stop_points_selected: 'All stop points from route cannot be selected.'
routing_constraint_zones:
actions:
new: New routing constraint zone
diff --git a/config/locales/routing_constraint_zones.fr.yml b/config/locales/routing_constraint_zones.fr.yml
index 556067710..36dcf9301 100644
--- a/config/locales/routing_constraint_zones.fr.yml
+++ b/config/locales/routing_constraint_zones.fr.yml
@@ -9,6 +9,9 @@ fr:
line: Ligne
created_at: "Créé le"
updated_at: "Edité le"
+ objectid: Object ID
+ stop_points_count: Nombre d'arrêts
+ route: Itinéraire
errors:
models:
routing_constraint_zone: