From 6ae7fedf7129803b235cf298623b45a8aae37b50 Mon Sep 17 00:00:00 2001 From: "philip.cline" Date: Tue, 17 Oct 2023 15:15:53 -0400 Subject: [PATCH 1/4] fix(routelayout): fix pagination --- .../reporter/components/RouteLayout.js | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/lib/manager/components/reporter/components/RouteLayout.js b/lib/manager/components/reporter/components/RouteLayout.js index b508bf935..d5ef7c458 100644 --- a/lib/manager/components/reporter/components/RouteLayout.js +++ b/lib/manager/components/reporter/components/RouteLayout.js @@ -17,13 +17,13 @@ import Loading from '../../../../common/components/Loading' import ActiveDateTimeFilter from '../containers/ActiveDateTimeFilter' import * as routesActions from '../../../../gtfs/actions/routes' import * as patternsActions from '../../../../gtfs/actions/patterns' -import TripsPerHourChart from './TripsPerHourChart' - import type {Props as ContainerProps} from '../containers/Routes' import type {RouteRowData} from '../../../selectors' import type {FetchStatus} from '../../../../types' import type {AllRoutesSubState, RouteListItem} from '../../../../types/reducers' +import TripsPerHourChart from './TripsPerHourChart' + type Props = ContainerProps & { allRoutes: AllRoutesSubState, fetchRouteDetails: typeof routesActions.fetchRouteDetails, @@ -98,6 +98,20 @@ export default class RouteLayout extends Component { // order to see items 1 - 4). const extraPage = +(routeOffset % PAGE_SIZE > 0) const activePage = Math.floor(routeOffset / PAGE_SIZE) + 1 + extraPage + const numPages = Math.ceil(numRoutes / PAGE_SIZE) + + const paginationItems = [] + for (let pageNum = 1; pageNum <= numPages; pageNum++) { + paginationItems.push( + this._onPaginationSelect(+e.target.text)} + > + {pageNum} + + ) + } return (
@@ -144,16 +158,16 @@ export default class RouteLayout extends Component { selectTab={selectTab} /> ))} - + {numPages > 1 && +
+ console.log('yoyo')} + > + {paginationItems} + +
+ } } From 096e9afbd610a7fbb6aa36ba325af690b0232411 Mon Sep 17 00:00:00 2001 From: "philip.cline" Date: Mon, 23 Oct 2023 10:32:34 -0700 Subject: [PATCH 2/4] refactor(RouteLayout): i18n --- i18n/english.yml | 8 +++++++ i18n/german.yml | 8 +++++++ i18n/polish.yml | 8 +++++++ .../reporter/components/RouteLayout.js | 23 +++++++++++-------- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/i18n/english.yml b/i18n/english.yml index ec643f86f..75bd98df5 100644 --- a/i18n/english.yml +++ b/i18n/english.yml @@ -1152,6 +1152,14 @@ components: line: Line priority: Priority problemType: Problem Type + RouteLayout: + errorOccurred: An error occurred while trying to fetch the data + jumpToRoute: Jump to a Route + route: "Route:" + RouteRow: + patterns: "%num% Patterns" + stops: "%num% Stops" + trips: "%num% Trips" SelectFileModal: ok: OK cancel: Cancel diff --git a/i18n/german.yml b/i18n/german.yml index 88917dab1..10cd74353 100644 --- a/i18n/german.yml +++ b/i18n/german.yml @@ -1156,6 +1156,14 @@ components: und eine detailierte Beschreibung der Schritte, die Sie zuvor ausgeführt haben an %supportEmail%. view: Ansehen + RouteLayout: + errorOccurred: An error occurred while trying to fetch the data + jumpToRoute: Jump to a Route + route: "Route:" + RouteRow: + patterns: "%num% Patterns" + stops: "%num% Stops" + trips: "%num% Trips" SelectFileModal: cancel: Abbrechen ok: OK diff --git a/i18n/polish.yml b/i18n/polish.yml index f643f2eb5..1a9d38cfe 100644 --- a/i18n/polish.yml +++ b/i18n/polish.yml @@ -1140,6 +1140,14 @@ components: the following text (current URL and error details), and a detailed description of the steps you followed to %supportEmail%. view: View + RouteLayout: + errorOccurred: An error occurred while trying to fetch the data + jumpToRoute: Jump to a Route + route: "Route:" + RouteRow: + patterns: "%num% Patterns" + stops: "%num% Stops" + trips: "%num% Trips" SelectFileModal: cancel: Cancel ok: OK diff --git a/lib/manager/components/reporter/components/RouteLayout.js b/lib/manager/components/reporter/components/RouteLayout.js index d5ef7c458..9cc6c0bfd 100644 --- a/lib/manager/components/reporter/components/RouteLayout.js +++ b/lib/manager/components/reporter/components/RouteLayout.js @@ -17,6 +17,7 @@ import Loading from '../../../../common/components/Loading' import ActiveDateTimeFilter from '../containers/ActiveDateTimeFilter' import * as routesActions from '../../../../gtfs/actions/routes' import * as patternsActions from '../../../../gtfs/actions/patterns' +import { getComponentMessages } from '../../../../common/util/config' import type {Props as ContainerProps} from '../containers/Routes' import type {RouteRowData} from '../../../selectors' import type {FetchStatus} from '../../../../types' @@ -40,6 +41,8 @@ type Props = ContainerProps & { const PAGE_SIZE = 10 export default class RouteLayout extends Component { + messages = getComponentMessages('RouteLayout') + componentWillMount () { const {fetchRouteDetails, fetchRoutes, fetchStatus, version} = this.props const {namespace} = version @@ -117,13 +120,14 @@ export default class RouteLayout extends Component {
{allRoutes !== null && allRoutes.data !== null && - +