aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorThomas Haddad2017-03-13 16:58:45 +0100
committerThomas Haddad2017-03-13 16:58:45 +0100
commita473fe3aa7a73df1a85a89eb678097bfe8bfe931 (patch)
treee57de0119f7e88045831364fc72106f9cd3eb397 /app/assets/javascripts
parent2180edc34c7936e3e9a507a36cdf2200553bed90 (diff)
downloadchouette-core-a473fe3aa7a73df1a85a89eb678097bfe8bfe931.tar.bz2
Refs #2776: Fix TotalCount with new json, and check when no vj
Signed-off-by: Thomas Shawarma Haddad <thomas.haddad@af83.com>
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js5
-rw-r--r--app/assets/javascripts/es6_browserified/vehicle_journeys/components/Navigate.js4
-rw-r--r--app/assets/javascripts/es6_browserified/vehicle_journeys/index.js2
-rw-r--r--app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/pagination.js2
4 files changed, 12 insertions, 1 deletions
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js
index b82f082ce..5069e5945 100644
--- a/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js
+++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/actions/index.js
@@ -228,6 +228,10 @@ const actions = {
type: 'UPDATE_TOTAL_COUNT',
diff
}),
+ receiveTotalCount: (total) => ({
+ type: 'RECEIVE_TOTAL_COUNT',
+ total
+ }),
fetchVehicleJourneys : (dispatch, currentPage, nextPage, queryString) => {
if(currentPage == undefined){
currentPage = 1
@@ -301,6 +305,7 @@ const actions = {
})
}
dispatch(actions.receiveVehicleJourneys(vehicleJourneys))
+ dispatch(actions.receiveTotalCount(json.total))
}
})
},
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/Navigate.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/Navigate.js
index 9b95c1bc6..2d5923a4d 100644
--- a/app/assets/javascripts/es6_browserified/vehicle_journeys/components/Navigate.js
+++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/components/Navigate.js
@@ -7,6 +7,10 @@ let Navigate = ({ dispatch, vehicleJourneys, pagination, status, filters}) => {
let firstPage = 1
let lastPage = Math.ceil(pagination.totalCount / pagination.perPage)
let minVJ = (pagination.page - 1) * pagination.perPage + 1
+ if (pagination.totalCount == 0){
+ minVJ = 0
+ lastPage = 1
+ }
let maxVJ = Math.min((pagination.page * pagination.perPage), pagination.totalCount)
if(status.isFetching == true) {
return false
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js
index 517f5c922..7bca4911a 100644
--- a/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js
+++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/index.js
@@ -53,7 +53,7 @@ var initialState = {
stopPointsList: window.stopPoints,
pagination: {
page : 1,
- totalCount: window.vehicleJourneysLength,
+ totalCount: 0,
perPage: window.vehicleJourneysPerPage,
stateChanged: false
},
diff --git a/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/pagination.js b/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/pagination.js
index 203e37e5a..31c855a2f 100644
--- a/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/pagination.js
+++ b/app/assets/javascripts/es6_browserified/vehicle_journeys/reducers/pagination.js
@@ -18,6 +18,8 @@ const pagination = (state = {}, action) => {
return Object.assign({}, state, {stateChanged: true})
case 'RESET_PAGINATION':
return Object.assign({}, state, {page: 1, stateChanged: false})
+ case 'RECEIVE_TOTAL_COUNT':
+ return Object.assign({}, state, {totalCount: action.total})
case 'UPDATE_TOTAL_COUNT':
return Object.assign({}, state, {totalCount : state.totalCount - action.diff })
default: