Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into upstream-merge-2…
Browse files Browse the repository at this point in the history
…024-09-30
  • Loading branch information
leonardehrenfried committed Sep 30, 2024
2 parents f6ec36d + b174c25 commit 00fdbff
Show file tree
Hide file tree
Showing 18 changed files with 358 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export function ItineraryPaginationControl({
return (
<div style={{ display: 'flex', justifyContent: 'space-evenly', margin: '1rem 0 ' }}>
<Button
variant="outline-primary"
size="sm"
disabled={!previousPageCursor || loading}
onClick={() => {
previousPageCursor && onPagination(previousPageCursor);
Expand All @@ -22,6 +24,8 @@ export function ItineraryPaginationControl({
Previous page
</Button>{' '}
<Button
variant="outline-primary"
size="sm"
disabled={!nextPageCursor || loading}
onClick={() => {
nextPageCursor && onPagination(nextPageCursor);
Expand Down
17 changes: 12 additions & 5 deletions client/src/components/SearchBar/GraphiQLRouteButton.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { Button } from 'react-bootstrap';
import { TripQueryVariables } from '../../gql/graphql.ts';
import { queryAsString } from '../../static/query/tripQuery.tsx';
import graphqlIcon from '../../static/img/graphql-solid.svg';

const graphiQLUrl = import.meta.env.VITE_GRAPHIQL_URL;

function GraphiQLRouteButton({ tripQueryVariables }: { tripQueryVariables: TripQueryVariables }) {
const formattedVariables = encodeURIComponent(JSON.stringify(tripQueryVariables));
const formattedQuery = encodeURIComponent(queryAsString);

const hint = 'Open in GraphiQL';

return (
<div className="search-bar-route-button-wrapper">
<Button href={graphiQLUrl + '&query=' + formattedQuery + '&variables=' + formattedVariables} target={'_blank'}>
GraphiQL
</Button>
</div>
<Button
title={hint}
href={graphiQLUrl + '&query=' + formattedQuery + '&variables=' + formattedVariables}
target={'_blank'}
>
<img alt={hint} title={hint} src={graphqlIcon} width="20" height="20" className="d-inline-block align-middle" />
</Button>
);
}

export default GraphiQLRouteButton;
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ export function ItineraryFilterDebugSelect({
return (
<Form.Group>
<Form.Label column="sm" htmlFor="itineraryDebugFilterSelect">
Itinerary filter debug
Filter debug
</Form.Label>
<Form.Select
id="itineraryDebugFilterSelect"
size="sm"
className="input-medium"
onChange={(e) => {
setTripQueryVariables({
...tripQueryVariables,
Expand Down
1 change: 1 addition & 0 deletions client/src/components/SearchBar/LocationInputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function LocationInputField({ location, id, label }: { location: Location
id={id}
size="sm"
placeholder="[Click in map]"
className="input-medium"
// Intentionally empty for now, but needed because of
// https://react.dev/reference/react-dom/components/input#controlling-an-input-with-a-state-variable
onChange={() => {}}
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/SearchBar/NumTripPatternsInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export function NumTripPatternsInput({
return (
<Form.Group>
<Form.Label column="sm" htmlFor="numTripPatternsInput">
Number of trip patterns
Num. results
</Form.Label>
<Form.Control
type="number"
id="numTripPatternsInput"
size="sm"
placeholder="12"
min={1}
className="input-small"
value={tripQueryVariables.numTripPatterns || ''}
onChange={(event) =>
setTripQueryVariables({
Expand Down
28 changes: 18 additions & 10 deletions client/src/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Spinner } from 'react-bootstrap';
import { Button, ButtonGroup, Spinner } from 'react-bootstrap';
import { ServerInfo, TripQueryVariables } from '../../gql/graphql.ts';
import { LocationInputField } from './LocationInputField.tsx';
import { DepartureArrivalSelect } from './DepartureArrivalSelect.tsx';
Expand All @@ -15,6 +15,7 @@ import { ServerInfoTooltip } from './ServerInfoTooltip.tsx';
import { useRef, useState } from 'react';
import logo from '../../static/img/otp-logo.svg';
import GraphiQLRouteButton from './GraphiQLRouteButton.tsx';
import WheelchairAccessibleCheckBox from './WheelchairAccessibleCheckBox.tsx';

type SearchBarProps = {
onRoute: () => void;
Expand Down Expand Up @@ -50,17 +51,24 @@ export function SearchBar({ onRoute, tripQueryVariables, setTripQueryVariables,
tripQueryVariables={tripQueryVariables}
setTripQueryVariables={setTripQueryVariables}
/>
<WheelchairAccessibleCheckBox
tripQueryVariables={tripQueryVariables}
setTripQueryVariables={setTripQueryVariables}
/>

<div className="search-bar-route-button-wrapper">
<Button variant="primary" onClick={() => onRoute()} disabled={loading}>
{loading && (
<>
<Spinner as="span" animation="border" size="sm" role="status" aria-hidden="true" />{' '}
</>
)}
Route
</Button>
<ButtonGroup>
<Button variant="primary" onClick={() => onRoute()} disabled={loading}>
{loading && (
<>
<Spinner as="span" animation="border" size="sm" role="status" aria-hidden="true" />{' '}
</>
)}
Route
</Button>
<GraphiQLRouteButton tripQueryVariables={tripQueryVariables}></GraphiQLRouteButton>
</ButtonGroup>
</div>
<GraphiQLRouteButton tripQueryVariables={tripQueryVariables}></GraphiQLRouteButton>
</div>
);
}
1 change: 1 addition & 0 deletions client/src/components/SearchBar/SearchWindowInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function SearchWindowInput({
size="sm"
placeholder="(in minutes)"
min={1}
className="input-small"
value={tripQueryVariables.searchWindow || ''}
onChange={(event) =>
setTripQueryVariables({
Expand Down
35 changes: 35 additions & 0 deletions client/src/components/SearchBar/WheelchairAccessibleCheckBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Form } from 'react-bootstrap';
import wheelchairIcon from '../../static/img/wheelchair.svg';
import { TripQueryVariables } from '../../gql/graphql.ts';

export default function WheelchairAccessibleCheckBox({
tripQueryVariables,
setTripQueryVariables,
}: {
tripQueryVariables: TripQueryVariables;
setTripQueryVariables: (tripQueryVariables: TripQueryVariables) => void;
}) {
return (
<Form.Group>
<Form.Label column="sm" htmlFor="wheelchairAccessibleCheck">
<img
alt="Wheelchair Accessible Trip"
title="Wheelchair Accessible Trip"
src={wheelchairIcon}
width="20"
height="20"
className="d-inline-block align-middle"
/>
</Form.Label>
<Form.Check
id="wheelchairAccessible"
onChange={(e) => {
setTripQueryVariables({
...tripQueryVariables,
wheelchairAccessible: e.target.checked,
});
}}
></Form.Check>
</Form.Group>
);
}
4 changes: 4 additions & 0 deletions client/src/static/img/graphql-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions client/src/static/img/graphql.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions client/src/static/img/wheelchair.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 00fdbff

Please sign in to comment.