From 037b3182dd0616cd0f9833929f06b37ef69ecec6 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 31 Mar 2021 17:00:08 +0200 Subject: [PATCH 01/35] QMAPS-1883 remove close buttons on all panels (on mobile) and on POI panels (on all devices) --- src/components/ui/Panel.jsx | 6 ++++-- src/panel/poi/PoiPanel.jsx | 6 +----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/ui/Panel.jsx b/src/components/ui/Panel.jsx index 60e0cd6aa..544f62e5c 100644 --- a/src/components/ui/Panel.jsx +++ b/src/components/ui/Panel.jsx @@ -2,7 +2,7 @@ import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { fire } from 'src/libs/customEvents'; -import { DeviceContext } from 'src/libs/device'; +import { DeviceContext, isMobileDevice } from 'src/libs/device'; import { PanelContext } from 'src/libs/panelContext'; import { CloseButton, FloatingItems } from 'src/components/ui'; @@ -330,7 +330,9 @@ class Panel extends React.Component { {floatingItemsRight && size !== 'maximized' && ( )} - {onClose && } + {onClose && !isMobileDevice() && ( + + )} {isMobile && resizable && (
this.handleHeaderClick()}>
diff --git a/src/panel/poi/PoiPanel.jsx b/src/panel/poi/PoiPanel.jsx index 533595a60..dcd0ee4d8 100644 --- a/src/panel/poi/PoiPanel.jsx +++ b/src/panel/poi/PoiPanel.jsx @@ -17,7 +17,7 @@ import { addToFavorites, removeFromFavorites, isInFavorites } from 'src/adapters import PoiItem from 'src/components/PoiItem'; import { isNullOrEmpty } from 'src/libs/object'; import { DeviceContext } from 'src/libs/device'; -import { Flex, Panel, PanelNav, CloseButton, Divider, Button } from 'src/components/ui'; +import { Flex, Panel, PanelNav, Divider, Button } from 'src/components/ui'; import { BackToQwantButton } from 'src/components/BackToQwantButton'; const covid19Enabled = (nconf.get().covid19 || {}).enabled; @@ -276,10 +276,6 @@ export default class PoiPanel extends React.Component { withOpeningHours onClick={this.center} /> -
Date: Wed, 31 Mar 2021 17:41:20 +0200 Subject: [PATCH 02/35] QMAPS-1883 fix close button on itinerary routes list --- src/panel/direction/DirectionPanel.jsx | 1 + src/panel/direction/RouteResult.jsx | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/panel/direction/DirectionPanel.jsx b/src/panel/direction/DirectionPanel.jsx index 512d6e93c..0ba7fc5e1 100644 --- a/src/panel/direction/DirectionPanel.jsx +++ b/src/panel/direction/DirectionPanel.jsx @@ -408,6 +408,7 @@ export default class DirectionPanel extends React.Component { destination={destination} toggleDetails={() => this.toggleDetails()} selectRoute={this.selectRoute} + onClose={this.onClose} /> ); diff --git a/src/panel/direction/RouteResult.jsx b/src/panel/direction/RouteResult.jsx index ce61b6893..94ba7ffc3 100644 --- a/src/panel/direction/RouteResult.jsx +++ b/src/panel/direction/RouteResult.jsx @@ -5,6 +5,7 @@ import { listen, unListen } from 'src/libs/customEvents'; import Telemetry from 'src/libs/telemetry'; import RoutesList from './RoutesList'; +import { CloseButton } from '../../components/ui'; import { SourceFooter } from 'src/components/ui'; const RouteResult = ({ @@ -18,6 +19,7 @@ const RouteResult = ({ activeDetails, selectRoute, toggleDetails, + onClose, }) => { useEffect(() => { const routeSelectedOnMapHandler = listen('select_road_map', onSelectRoute); @@ -63,6 +65,7 @@ const RouteResult = ({ return ( <>
+ Date: Wed, 7 Apr 2021 11:10:57 +0200 Subject: [PATCH 03/35] QMAPS-1883 fix tests, fill field in search field if not from PoI list --- src/panel/poi/PoiPanel.jsx | 9 +++++++++ tests/integration/tests/poi.desktop.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/panel/poi/PoiPanel.jsx b/src/panel/poi/PoiPanel.jsx index dcd0ee4d8..dad3b04f6 100644 --- a/src/panel/poi/PoiPanel.jsx +++ b/src/panel/poi/PoiPanel.jsx @@ -19,6 +19,7 @@ import { isNullOrEmpty } from 'src/libs/object'; import { DeviceContext } from 'src/libs/device'; import { Flex, Panel, PanelNav, Divider, Button } from 'src/components/ui'; import { BackToQwantButton } from 'src/components/BackToQwantButton'; +import SearchInput from '../../ui_components/search_input'; const covid19Enabled = (nconf.get().covid19 || {}).enabled; @@ -238,6 +239,7 @@ export default class PoiPanel extends React.Component { ); } + // If source is a PoI list: show a button to return to the list (only visible on desktop) if (backAction !== this.closeAction) { return ( @@ -248,6 +250,13 @@ export default class PoiPanel extends React.Component { ); } + // Else: show PoI name in search field + else { + SearchInput.setInputValue(poi.name); + const topBarHandle = document.querySelector('.top_bar'); + topBarHandle.classList.add('top_bar--search_filled'); + } + return null; }; diff --git a/tests/integration/tests/poi.desktop.js b/tests/integration/tests/poi.desktop.js index b16520c1e..2e8188e80 100644 --- a/tests/integration/tests/poi.desktop.js +++ b/tests/integration/tests/poi.desktop.js @@ -84,7 +84,7 @@ test('add a poi as favorite and find it back in the favorite menu', async () => expect(await exists(page, '.poiTitle')).toBeTruthy(); expect(await exists(page, '.poi_panel')).toBeTruthy(); await page.click('.poi_panel__actions .poi_panel__action__favorite'); - await page.click('.poi_panel .closeButton'); + await page.click('.search_form__clear .icon-x'); // we check that the first favorite item is our poi await toggleFavoritePanel(page); let fav = await getFavorites(page); From 376566b787fcfd224eac9fa3bef5ac208b6aeb6a Mon Sep 17 00:00:00 2001 From: bbecquet Date: Fri, 2 Apr 2021 10:50:42 +0200 Subject: [PATCH 04/35] Use ismobile from context --- src/components/ui/Panel.jsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/ui/Panel.jsx b/src/components/ui/Panel.jsx index 544f62e5c..0cc007693 100644 --- a/src/components/ui/Panel.jsx +++ b/src/components/ui/Panel.jsx @@ -2,7 +2,7 @@ import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { fire } from 'src/libs/customEvents'; -import { DeviceContext, isMobileDevice } from 'src/libs/device'; +import { DeviceContext } from 'src/libs/device'; import { PanelContext } from 'src/libs/panelContext'; import { CloseButton, FloatingItems } from 'src/components/ui'; @@ -330,9 +330,7 @@ class Panel extends React.Component { {floatingItemsRight && size !== 'maximized' && ( )} - {onClose && !isMobileDevice() && ( - - )} + {onClose && !isMobile && } {isMobile && resizable && (
this.handleHeaderClick()}>
From 5ffcc0fea394c5cd442be78fc1dd7a290dd4f5d7 Mon Sep 17 00:00:00 2001 From: bbecquet Date: Fri, 2 Apr 2021 11:02:00 +0200 Subject: [PATCH 05/35] No button on desktop route result --- src/components/ui/Panel.jsx | 3 ++- src/panel/direction/DirectionPanel.jsx | 1 - src/panel/direction/RouteResult.jsx | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/ui/Panel.jsx b/src/components/ui/Panel.jsx index 0cc007693..ba1f8e958 100644 --- a/src/components/ui/Panel.jsx +++ b/src/components/ui/Panel.jsx @@ -51,6 +51,7 @@ class Panel extends React.Component { isMapBottomUIDisplayed: PropTypes.bool, floatingItems: PropTypes.arrayOf(PropTypes.object), onTransitionEnd: PropTypes.func, + onClose: PropTypes.func, }; static defaultProps = { @@ -330,7 +331,7 @@ class Panel extends React.Component { {floatingItemsRight && size !== 'maximized' && ( )} - {onClose && !isMobile && } + {onClose && } {isMobile && resizable && (
this.handleHeaderClick()}>
diff --git a/src/panel/direction/DirectionPanel.jsx b/src/panel/direction/DirectionPanel.jsx index 0ba7fc5e1..512d6e93c 100644 --- a/src/panel/direction/DirectionPanel.jsx +++ b/src/panel/direction/DirectionPanel.jsx @@ -408,7 +408,6 @@ export default class DirectionPanel extends React.Component { destination={destination} toggleDetails={() => this.toggleDetails()} selectRoute={this.selectRoute} - onClose={this.onClose} /> ); diff --git a/src/panel/direction/RouteResult.jsx b/src/panel/direction/RouteResult.jsx index 94ba7ffc3..ff6381aab 100644 --- a/src/panel/direction/RouteResult.jsx +++ b/src/panel/direction/RouteResult.jsx @@ -5,7 +5,6 @@ import { listen, unListen } from 'src/libs/customEvents'; import Telemetry from 'src/libs/telemetry'; import RoutesList from './RoutesList'; -import { CloseButton } from '../../components/ui'; import { SourceFooter } from 'src/components/ui'; const RouteResult = ({ @@ -19,7 +18,6 @@ const RouteResult = ({ activeDetails, selectRoute, toggleDetails, - onClose, }) => { useEffect(() => { const routeSelectedOnMapHandler = listen('select_road_map', onSelectRoute); From e1f6d1aab5dcd10c35177caee791f331cf683248 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 7 Apr 2021 11:13:37 +0200 Subject: [PATCH 06/35] QMAPS-1883 fix tests --- tests/integration/tests/poi.desktop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/poi.desktop.js b/tests/integration/tests/poi.desktop.js index 2e8188e80..51537d41e 100644 --- a/tests/integration/tests/poi.desktop.js +++ b/tests/integration/tests/poi.desktop.js @@ -99,7 +99,7 @@ test('add a poi as favorite and find it back in the favorite menu', async () => expect(await exists(page, '.poi_panel')).toBeTruthy(); await page.click('.poi_panel__actions .poi_panel__action__favorite'); - await page.click('.poi_panel .closeButton'); + await page.click('.search_form__clear .icon-x'); // it should disappear from the favorites await toggleFavoritePanel(page); fav = await getFavorites(page); From 105c6f2797f274337d0a897ac4ba6540088d3272 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 7 Apr 2021 11:44:33 +0200 Subject: [PATCH 07/35] QMAPS-1883 fix tests --- tests/integration/tests/autocomplete.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index f859d5436..c2d7e0057 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -150,8 +150,7 @@ test('mouse navigation', async () => { await autocompleteHelper.clickResult(1); const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - const expectedLabelName = mockAutocomplete.features[0].properties.geocoding.name; - expect(selectedSearchValue).toEqual(expectedLabelName); + expect(selectedSearchValue).toEqual("Musée d'Orsay"); }); test('move to on click', async () => { From ff2871a849109dfd442f1e52437c835ac1636b87 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 7 Apr 2021 14:49:12 +0200 Subject: [PATCH 08/35] QMAPS-1883 fix tests --- tests/integration/tests/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index c2d7e0057..baf3b88a9 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -150,7 +150,7 @@ test('mouse navigation', async () => { await autocompleteHelper.clickResult(1); const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - expect(selectedSearchValue).toEqual("Musée d'Orsay"); + expect(selectedSearchValue).toEqual('test result 1'); }); test('move to on click', async () => { From 08be2ee1310daf0246a320706483cd3d01f69e6e Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 7 Apr 2021 15:02:17 +0200 Subject: [PATCH 09/35] QMAPS-1883 fix tests --- tests/integration/tests/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index baf3b88a9..c2d7e0057 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -150,7 +150,7 @@ test('mouse navigation', async () => { await autocompleteHelper.clickResult(1); const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - expect(selectedSearchValue).toEqual('test result 1'); + expect(selectedSearchValue).toEqual("Musée d'Orsay"); }); test('move to on click', async () => { From 43fd5b6a34fc9ffe3d4aefc44c1171db4f185626 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 7 Apr 2021 15:11:20 +0200 Subject: [PATCH 10/35] QMAPS-1883 fix tests, always put poi name in search field --- src/panel/poi/PoiPanel.jsx | 12 +++++------- tests/integration/tests/autocomplete.js | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/panel/poi/PoiPanel.jsx b/src/panel/poi/PoiPanel.jsx index dad3b04f6..420ae0bb4 100644 --- a/src/panel/poi/PoiPanel.jsx +++ b/src/panel/poi/PoiPanel.jsx @@ -219,6 +219,11 @@ export default class PoiPanel extends React.Component { return null; } + // Show PoI name in search field + SearchInput.setInputValue(poi.name); + const topBarHandle = document.querySelector('.top_bar'); + topBarHandle.classList.add('top_bar--search_filled'); + const backAction = poiFilters.category || poiFilters.query ? this.backToList @@ -250,13 +255,6 @@ export default class PoiPanel extends React.Component { ); } - // Else: show PoI name in search field - else { - SearchInput.setInputValue(poi.name); - const topBarHandle = document.querySelector('.top_bar'); - topBarHandle.classList.add('top_bar--search_filled'); - } - return null; }; diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index c2d7e0057..a16dd7b47 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -150,7 +150,7 @@ test('mouse navigation', async () => { await autocompleteHelper.clickResult(1); const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - expect(selectedSearchValue).toEqual("Musée d'Orsay"); + expect(selectedSearchValue).toEqual("test result 1"); }); test('move to on click', async () => { @@ -244,7 +244,7 @@ test('Search Query', async () => { responseHandler.addPreparedResponse(mockAutocomplete, /autocomplete/); await page.goto('about:blank'); - const searchQuery = 'test'; + const searchQuery = "Musée d'Orsay"; await page.goto(`${APP_URL}/?q=${searchQuery}`); const searchValue = await getInputValue(page, '#search'); From 7863e9d4ade696f36f6d6af5342b3b87c9e725d4 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 7 Apr 2021 15:11:55 +0200 Subject: [PATCH 11/35] QMAPS-1883 fix lint --- tests/integration/tests/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index a16dd7b47..fde4b6105 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -150,7 +150,7 @@ test('mouse navigation', async () => { await autocompleteHelper.clickResult(1); const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - expect(selectedSearchValue).toEqual("test result 1"); + expect(selectedSearchValue).toEqual('test result 1'); }); test('move to on click', async () => { From d6a143b9270ede666814ad49dcc583aa7f2c82cd Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 7 Apr 2021 17:00:36 +0200 Subject: [PATCH 12/35] QMAPS-1883 add return arrow on PoI panel on mobile when the source il a list --- src/panel/poi/PoiPanel.jsx | 13 ++++++++++- src/scss/includes/search_form.scss | 29 ++++++++++++++++++++++--- tests/integration/tests/autocomplete.js | 5 +++-- views/index.ejs | 1 + 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/panel/poi/PoiPanel.jsx b/src/panel/poi/PoiPanel.jsx index 420ae0bb4..08979b693 100644 --- a/src/panel/poi/PoiPanel.jsx +++ b/src/panel/poi/PoiPanel.jsx @@ -57,6 +57,13 @@ export default class PoiPanel extends React.Component { this.setState({ isPoiInFavorite }); } }); + + // Show return arrow on mobile if user comes from PoI / favorites list + const { poiFilters, isFromFavorite } = this.props; + if (poiFilters.category || poiFilters.query || isFromFavorite) { + const topBarHandle = document.querySelector('.top_bar'); + topBarHandle.classList.add('top_bar--poi-from-list'); + } } componentDidUpdate(prevProps) { @@ -72,6 +79,10 @@ export default class PoiPanel extends React.Component { fire('mobile_direction_button_visibility', true); // Clear direction shortcut cb to reset default action fire('set_direction_shortcut_callback', null); + + // Hide return arrow on mobile + const topBarHandle = document.querySelector('.top_bar'); + topBarHandle.classList.remove('top_bar--poi-from-list'); } loadPois = () => { @@ -244,7 +255,7 @@ export default class PoiPanel extends React.Component { ); } - // If source is a PoI list: show a button to return to the list (only visible on desktop) + // If source is a PoI list: show a button to return to the list if (backAction !== this.closeAction) { return ( diff --git a/src/scss/includes/search_form.scss b/src/scss/includes/search_form.scss index 8c12b7aee..819387f54 100644 --- a/src/scss/includes/search_form.scss +++ b/src/scss/includes/search_form.scss @@ -86,8 +86,9 @@ input[type="search"] { } } -// Return arrow -.search_form__return { +// Return arrows +.search_form__return, +.search_form__return-to-list { display: none; } @@ -191,7 +192,8 @@ input[type="search"] { font-size: 14px; } - .search_form__return { + .search_form__return, + .search_form__return-to-list { display: none; font-size: 20px; text-align: center; @@ -303,4 +305,25 @@ input[type="search"] { display: none; } } + + // When a PoI Panel is displayed + .top_bar--poi-from-list { + + // Show the return arrow + .search_form__return-to-list { + display: block; + } + + // If the search field is focused, hide it + &.top_bar--search_focus { + .search_form__return-to-list { + display: none; + } + } + + // Make room for it on the left of the field + .search_form__wrapper { + padding-left: $spacing-xxl-3; + } + } } diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index fde4b6105..60bbf85f9 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -149,8 +149,9 @@ test('mouse navigation', async () => { expect(searchValue.trim()).toEqual(TypedSearch); await autocompleteHelper.clickResult(1); - const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - expect(selectedSearchValue).toEqual('test result 1'); + //const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); + //const expectedLabelName = mockAutocomplete.features[0].properties.geocoding.name; + //expect(selectedSearchValue).toEqual(expectedLabelName); }); test('move to on click', async () => { diff --git a/views/index.ejs b/views/index.ejs index 7b08b7eb9..41ede343d 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -49,6 +49,7 @@ >
+
From 17c024b17fff73b4c123f35b112ff67e7d84032d Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 7 Apr 2021 17:12:49 +0200 Subject: [PATCH 13/35] QMAPS-1883 fix test --- tests/integration/tests/poi.desktop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/poi.desktop.js b/tests/integration/tests/poi.desktop.js index 51537d41e..97611deaa 100644 --- a/tests/integration/tests/poi.desktop.js +++ b/tests/integration/tests/poi.desktop.js @@ -99,7 +99,7 @@ test('add a poi as favorite and find it back in the favorite menu', async () => expect(await exists(page, '.poi_panel')).toBeTruthy(); await page.click('.poi_panel__actions .poi_panel__action__favorite'); - await page.click('.search_form__clear .icon-x'); + await page.click('.search_form__clear'); // it should disappear from the favorites await toggleFavoritePanel(page); fav = await getFavorites(page); From 34767f53c440ddedb061c38c87bbdafbb4351086 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 7 Apr 2021 17:13:16 +0200 Subject: [PATCH 14/35] QMAPS-1883 fix test --- tests/integration/tests/poi.desktop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/poi.desktop.js b/tests/integration/tests/poi.desktop.js index 97611deaa..171b4f953 100644 --- a/tests/integration/tests/poi.desktop.js +++ b/tests/integration/tests/poi.desktop.js @@ -84,7 +84,7 @@ test('add a poi as favorite and find it back in the favorite menu', async () => expect(await exists(page, '.poiTitle')).toBeTruthy(); expect(await exists(page, '.poi_panel')).toBeTruthy(); await page.click('.poi_panel__actions .poi_panel__action__favorite'); - await page.click('.search_form__clear .icon-x'); + await page.click('.search_form__clear'); // we check that the first favorite item is our poi await toggleFavoritePanel(page); let fav = await getFavorites(page); From a8e915a3540f5ffbfe8fa8fe3e8fbe84fff2dec0 Mon Sep 17 00:00:00 2001 From: xem Date: Mon, 12 Apr 2021 09:52:20 +0200 Subject: [PATCH 15/35] QMAPS-1883 lint --- src/panel/poi/blocks/Covid19.jsx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/panel/poi/blocks/Covid19.jsx b/src/panel/poi/blocks/Covid19.jsx index 334d81d69..8315b1f2b 100644 --- a/src/panel/poi/blocks/Covid19.jsx +++ b/src/panel/poi/blocks/Covid19.jsx @@ -85,17 +85,19 @@ const getContent = ({ status, opening_hours, note, contribute_url }) => { const LocalizedWarning = ({ countryCode }) => { const { frInformationUrl } = useConfig('covid19'); - return
-

{_('Please comply with government travel restrictions.', 'covid19')}

- {countryCode === 'FR' && ( -

- {_('More information at', 'covid19')}{' '} - - gouvernement.fr/info-coronavirus - -

- )} -
+ return ( +
+

{_('Please comply with government travel restrictions.', 'covid19')}

+ {countryCode === 'FR' && ( +

+ {_('More information at', 'covid19')}{' '} + + gouvernement.fr/info-coronavirus + +

+ )} +
+ ); }; const LegalWarning = ({ countryCode }) => ( From 5bd6411ad84a54631f9cb91ca08a65a1004a8363 Mon Sep 17 00:00:00 2001 From: xem Date: Tue, 13 Apr 2021 17:35:06 +0200 Subject: [PATCH 16/35] QMAPS-1883 move return button logic in panelManager --- src/panel/PanelManager.jsx | 55 +++++++++++++++++++++++++++++++++++--- src/panel/poi/PoiPanel.jsx | 45 ++++++++----------------------- views/index.ejs | 2 +- 3 files changed, 64 insertions(+), 38 deletions(-) diff --git a/src/panel/PanelManager.jsx b/src/panel/PanelManager.jsx index 3e0cbc665..0ad3794a7 100644 --- a/src/panel/PanelManager.jsx +++ b/src/panel/PanelManager.jsx @@ -9,7 +9,7 @@ import CategoryPanel from 'src/panel/category/CategoryPanel'; import DirectionPanel from 'src/panel/direction/DirectionPanel'; import Telemetry from 'src/libs/telemetry'; import CategoryService from 'src/adapters/category_service'; -import { parseQueryString, getCurrentUrl } from 'src/libs/url_utils'; +import { parseQueryString, getCurrentUrl, buildQueryString } from 'src/libs/url_utils'; import { fire, listen } from 'src/libs/customEvents'; import { isNullOrEmpty } from 'src/libs/object'; import { isMobileDevice } from 'src/libs/device'; @@ -77,12 +77,17 @@ export default class PanelManager extends React.Component { const { ActivePanel, options } = this.state; if (prevState.ActivePanel !== ActivePanel || prevState.options !== options) { - // poiFilters indicate we are in a "list of POI" context, where markers should be persistent + // Not in a "list of PoI" context (options.poiFilters is null) if (isNullOrEmpty(options?.poiFilters)) { + // Markers are not persistent fire('remove_category_markers'); } + // Handle search bar's style and text content this.updateSearchBarContent(options); + + // Handle top bar's return button + this.updateTopBarReturnButton(options); } } @@ -104,6 +109,45 @@ export default class PanelManager extends React.Component { } } + updateTopBarReturnButton({ poiFilters = {} } = {}) { + const topBarReturnButton = document.querySelector('.search_form__return-to-list'); + const backAction = + poiFilters.category || poiFilters.query ? this.backToList : this.backToFavorite; + topBarReturnButton.onclick = e => { + backAction(e, poiFilters); + }; + } + + backToList(e, poiFilters) { + e.stopPropagation(); + const queryObject = {}; + const mappingParams = { + query: 'q', + category: 'type', + }; + + for (const name in poiFilters) { + if (!poiFilters[name]) { + continue; + } + const key = mappingParams[name]; + queryObject[key || name] = poiFilters[name]; + } + + const params = buildQueryString(queryObject); + const uri = `/places/${params}`; + + Telemetry.add(Telemetry.POI_BACKTOLIST); + fire('restore_location'); + window.app.navigateTo(uri); + } + + backToFavorite(e) { + e.stopPropagation(); + Telemetry.add(Telemetry.POI_BACKTOFAVORITE); + window.app.navigateTo('/favs'); + } + initRouter() { const router = this.props.router; @@ -134,7 +178,12 @@ export default class PanelManager extends React.Component { const poiId = poiUrl.split('@')[0]; this.setState({ ActivePanel: PoiPanel, - options: { ...options, poiId }, + options: { + ...options, + poiId, + backToList: this.backToList, + backToFavorite: this.backToFavorite, + }, panelSize: 'default', }); }); diff --git a/src/panel/poi/PoiPanel.jsx b/src/panel/poi/PoiPanel.jsx index 08979b693..be3cdd736 100644 --- a/src/panel/poi/PoiPanel.jsx +++ b/src/panel/poi/PoiPanel.jsx @@ -29,6 +29,8 @@ export default class PoiPanel extends React.Component { poi: PropTypes.object, poiFilters: PropTypes.object, centerMap: PropTypes.bool, + backToList: PropTypes.func, + backToFavorite: PropTypes.func, }; static defaultProps = { @@ -142,12 +144,6 @@ export default class PoiPanel extends React.Component { }); } - backToFavorite = e => { - e.stopPropagation(); - Telemetry.add(Telemetry.POI_BACKTOFAVORITE); - window.app.navigateTo('/favs'); - }; - getBestPoi() { return this.state.fullPoi || this.props.poi; } @@ -168,31 +164,6 @@ export default class PoiPanel extends React.Component { window.app.navigateTo('/'); }; - backToList = e => { - e.stopPropagation(); - const { poiFilters } = this.props; - const queryObject = {}; - const mappingParams = { - query: 'q', - category: 'type', - }; - - for (const name in poiFilters) { - if (!poiFilters[name]) { - continue; - } - const key = mappingParams[name]; - queryObject[key || name] = poiFilters[name]; - } - - const params = buildQueryString(queryObject); - const uri = `/places/${params}`; - - Telemetry.add(Telemetry.POI_BACKTOLIST); - fire('restore_location'); - window.app.navigateTo(uri); - }; - onClickPhoneNumber = () => { const poi = this.getBestPoi(); const source = poi.meta && poi.meta.source; @@ -237,9 +208,9 @@ export default class PoiPanel extends React.Component { const backAction = poiFilters.category || poiFilters.query - ? this.backToList + ? this.props.backToList : isFromFavorite - ? this.backToFavorite + ? this.props.backToFavorite : this.closeAction; const NavHeader = ({ isMobile }) => { @@ -259,7 +230,13 @@ export default class PoiPanel extends React.Component { if (backAction !== this.closeAction) { return ( - diff --git a/views/index.ejs b/views/index.ejs index 41ede343d..6f1ce6176 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -49,7 +49,7 @@ >
-
+
From 1cb8cc6c4ed4cb539924f83101e71fa4b5f5e471 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 14 Apr 2021 16:52:10 +0200 Subject: [PATCH 17/35] QMAPS-1883 fix everything from panelManager --- src/panel/PanelManager.jsx | 25 +++++++++++++++++++++++++ src/panel/poi/PoiPanel.jsx | 15 ++------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/panel/PanelManager.jsx b/src/panel/PanelManager.jsx index 0ad3794a7..f2302f01f 100644 --- a/src/panel/PanelManager.jsx +++ b/src/panel/PanelManager.jsx @@ -118,6 +118,12 @@ export default class PanelManager extends React.Component { }; } + // Hide return arrow on mobile + hideReturnButton() { + const topBarHandle = document.querySelector('.top_bar'); + topBarHandle.classList.remove('top_bar--poi-from-list'); + } + backToList(e, poiFilters) { e.stopPropagation(); const queryObject = {}; @@ -164,6 +170,7 @@ export default class PanelManager extends React.Component { }, panelSize: 'default', }); + this.hideReturnButton(); }); router.addRoute('noresult', '/noresult', (_, options) => { @@ -172,6 +179,7 @@ export default class PanelManager extends React.Component { panelSize: 'default', options: { ...options }, }); + this.hideReturnButton(); }); router.addRoute('POI', '/place/([^?]+)', async (poiUrl, options = {}) => { @@ -186,6 +194,18 @@ export default class PanelManager extends React.Component { }, panelSize: 'default', }); + + // Show return arrow (on mobile) if user comes from PoI / favorites list + const { poiFilters = {}, isFromFavorite } = options; + if (poiFilters.category || poiFilters.query || isFromFavorite) { + const topBarHandle = document.querySelector('.top_bar'); + topBarHandle.classList.add('top_bar--poi-from-list'); + } + + // Show PoI name in search field + SearchInput.setInputValue(options.poi.name); + const topBarHandle = document.querySelector('.top_bar'); + topBarHandle.classList.add('top_bar--search_filled'); }); router.addRoute('Favorites', '/favs', () => { @@ -194,6 +214,8 @@ export default class PanelManager extends React.Component { options: {}, panelSize: 'default', }); + + SearchInput.setInputValue(_('Favorites', 'search bar')); }); if (directionConf.enabled) { @@ -210,6 +232,7 @@ export default class PanelManager extends React.Component { options: { ...params, ...options, isPublicTransportActive }, panelSize: 'default', }); + this.hideReturnButton(); }); } @@ -220,6 +243,7 @@ export default class PanelManager extends React.Component { } else { router.routeUrl('/'); } + this.hideReturnButton(); }); // Default matching route @@ -232,6 +256,7 @@ export default class PanelManager extends React.Component { if (options?.focusSearch) { SearchInput.select(); } + this.hideReturnButton(); }); // Route the initial URL diff --git a/src/panel/poi/PoiPanel.jsx b/src/panel/poi/PoiPanel.jsx index be3cdd736..e9649561c 100644 --- a/src/panel/poi/PoiPanel.jsx +++ b/src/panel/poi/PoiPanel.jsx @@ -9,7 +9,7 @@ import PoiBlockContainer from './PoiBlockContainer'; import OsmContribution from 'src/components/OsmContribution'; import CategoryList from 'src/components/CategoryList'; import { isFromPagesJaunes, isFromOSM } from 'src/libs/pois'; -import { buildQueryString, shouldShowBackToQwant } from 'src/libs/url_utils'; +import { shouldShowBackToQwant } from 'src/libs/url_utils'; import IdunnPoi from 'src/adapters/poi/idunn_poi'; import Poi from 'src/adapters/poi/poi.js'; import { fire, listen, unListen } from 'src/libs/customEvents'; @@ -59,13 +59,6 @@ export default class PoiPanel extends React.Component { this.setState({ isPoiInFavorite }); } }); - - // Show return arrow on mobile if user comes from PoI / favorites list - const { poiFilters, isFromFavorite } = this.props; - if (poiFilters.category || poiFilters.query || isFromFavorite) { - const topBarHandle = document.querySelector('.top_bar'); - topBarHandle.classList.add('top_bar--poi-from-list'); - } } componentDidUpdate(prevProps) { @@ -81,10 +74,6 @@ export default class PoiPanel extends React.Component { fire('mobile_direction_button_visibility', true); // Clear direction shortcut cb to reset default action fire('set_direction_shortcut_callback', null); - - // Hide return arrow on mobile - const topBarHandle = document.querySelector('.top_bar'); - topBarHandle.classList.remove('top_bar--poi-from-list'); } loadPois = () => { @@ -201,7 +190,7 @@ export default class PoiPanel extends React.Component { return null; } - // Show PoI name in search field + // Ensure PoI name is present in search field SearchInput.setInputValue(poi.name); const topBarHandle = document.querySelector('.top_bar'); topBarHandle.classList.add('top_bar--search_filled'); From eb32f90e510fcf9ad80d02555488451be00cacd3 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 14 Apr 2021 16:57:05 +0200 Subject: [PATCH 18/35] QMAPS-1883 lint --- src/panel/PanelManager.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/panel/PanelManager.jsx b/src/panel/PanelManager.jsx index f2302f01f..fecbf3d60 100644 --- a/src/panel/PanelManager.jsx +++ b/src/panel/PanelManager.jsx @@ -1,3 +1,4 @@ +/* globals _ */ import React from 'react'; import PropTypes from 'prop-types'; import SearchInput from '../ui_components/search_input'; From 63ce524bd7a98af642bc7640d45dc3aadc9a5732 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 14 Apr 2021 17:05:11 +0200 Subject: [PATCH 19/35] QMAPS-1883 lint --- src/panel/direction/RouteResult.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/panel/direction/RouteResult.jsx b/src/panel/direction/RouteResult.jsx index ff6381aab..0e127e4a1 100644 --- a/src/panel/direction/RouteResult.jsx +++ b/src/panel/direction/RouteResult.jsx @@ -3,9 +3,8 @@ import React, { useCallback, useEffect } from 'react'; import PropTypes from 'prop-types'; import { listen, unListen } from 'src/libs/customEvents'; import Telemetry from 'src/libs/telemetry'; - import RoutesList from './RoutesList'; -import { SourceFooter } from 'src/components/ui'; +import { SourceFooter, CloseButton } from 'src/components/ui'; const RouteResult = ({ origin, From c50c094a9ca01bdd2ea67198deb811fd0861ec25 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 14 Apr 2021 17:11:07 +0200 Subject: [PATCH 20/35] QMAPS-1883 lint --- src/panel/direction/RouteResult.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/panel/direction/RouteResult.jsx b/src/panel/direction/RouteResult.jsx index 0e127e4a1..c1abf5259 100644 --- a/src/panel/direction/RouteResult.jsx +++ b/src/panel/direction/RouteResult.jsx @@ -62,7 +62,6 @@ const RouteResult = ({ return ( <>
- Date: Wed, 14 Apr 2021 17:11:22 +0200 Subject: [PATCH 21/35] QMAPS-1883 lint --- src/panel/direction/RouteResult.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panel/direction/RouteResult.jsx b/src/panel/direction/RouteResult.jsx index c1abf5259..36cb22d0a 100644 --- a/src/panel/direction/RouteResult.jsx +++ b/src/panel/direction/RouteResult.jsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import { listen, unListen } from 'src/libs/customEvents'; import Telemetry from 'src/libs/telemetry'; import RoutesList from './RoutesList'; -import { SourceFooter, CloseButton } from 'src/components/ui'; +import { SourceFooter } from 'src/components/ui'; const RouteResult = ({ origin, From fa5a61488d9a0e0839e4dfe4abac3815ba85f8de Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 14 Apr 2021 17:21:56 +0200 Subject: [PATCH 22/35] QMAPS-1883 broken test --- tests/integration/tests/poi.desktop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/poi.desktop.js b/tests/integration/tests/poi.desktop.js index 171b4f953..b7cc4cbbc 100644 --- a/tests/integration/tests/poi.desktop.js +++ b/tests/integration/tests/poi.desktop.js @@ -84,7 +84,7 @@ test('add a poi as favorite and find it back in the favorite menu', async () => expect(await exists(page, '.poiTitle')).toBeTruthy(); expect(await exists(page, '.poi_panel')).toBeTruthy(); await page.click('.poi_panel__actions .poi_panel__action__favorite'); - await page.click('.search_form__clear'); + //await page.click('.search_form__clear'); // we check that the first favorite item is our poi await toggleFavoritePanel(page); let fav = await getFavorites(page); From cc1701666ec09d456ad63e545ff5fd167ce9be62 Mon Sep 17 00:00:00 2001 From: xem Date: Mon, 19 Apr 2021 10:01:07 +0200 Subject: [PATCH 23/35] QMAPS-1883 broken test --- tests/integration/tests/poi.desktop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/poi.desktop.js b/tests/integration/tests/poi.desktop.js index b7cc4cbbc..fc2e7e694 100644 --- a/tests/integration/tests/poi.desktop.js +++ b/tests/integration/tests/poi.desktop.js @@ -99,7 +99,7 @@ test('add a poi as favorite and find it back in the favorite menu', async () => expect(await exists(page, '.poi_panel')).toBeTruthy(); await page.click('.poi_panel__actions .poi_panel__action__favorite'); - await page.click('.search_form__clear'); + //await page.click('.search_form__clear'); // it should disappear from the favorites await toggleFavoritePanel(page); fav = await getFavorites(page); From c846ad280521b8f82139a96bc7d7fc724735607d Mon Sep 17 00:00:00 2001 From: xem Date: Mon, 19 Apr 2021 10:50:20 +0200 Subject: [PATCH 24/35] QMAPS-1883 fix test --- tests/integration/tests/autocomplete.js | 8 ++++---- tests/integration/tests/poi.desktop.js | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index 60bbf85f9..f859d5436 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -149,9 +149,9 @@ test('mouse navigation', async () => { expect(searchValue.trim()).toEqual(TypedSearch); await autocompleteHelper.clickResult(1); - //const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - //const expectedLabelName = mockAutocomplete.features[0].properties.geocoding.name; - //expect(selectedSearchValue).toEqual(expectedLabelName); + const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); + const expectedLabelName = mockAutocomplete.features[0].properties.geocoding.name; + expect(selectedSearchValue).toEqual(expectedLabelName); }); test('move to on click', async () => { @@ -245,7 +245,7 @@ test('Search Query', async () => { responseHandler.addPreparedResponse(mockAutocomplete, /autocomplete/); await page.goto('about:blank'); - const searchQuery = "Musée d'Orsay"; + const searchQuery = 'test'; await page.goto(`${APP_URL}/?q=${searchQuery}`); const searchValue = await getInputValue(page, '#search'); diff --git a/tests/integration/tests/poi.desktop.js b/tests/integration/tests/poi.desktop.js index fc2e7e694..daec025ea 100644 --- a/tests/integration/tests/poi.desktop.js +++ b/tests/integration/tests/poi.desktop.js @@ -84,7 +84,6 @@ test('add a poi as favorite and find it back in the favorite menu', async () => expect(await exists(page, '.poiTitle')).toBeTruthy(); expect(await exists(page, '.poi_panel')).toBeTruthy(); await page.click('.poi_panel__actions .poi_panel__action__favorite'); - //await page.click('.search_form__clear'); // we check that the first favorite item is our poi await toggleFavoritePanel(page); let fav = await getFavorites(page); @@ -99,7 +98,6 @@ test('add a poi as favorite and find it back in the favorite menu', async () => expect(await exists(page, '.poi_panel')).toBeTruthy(); await page.click('.poi_panel__actions .poi_panel__action__favorite'); - //await page.click('.search_form__clear'); // it should disappear from the favorites await toggleFavoritePanel(page); fav = await getFavorites(page); From c003d4fa0d7c2ccfe3b614dd84468f1930b08084 Mon Sep 17 00:00:00 2001 From: xem Date: Mon, 19 Apr 2021 14:41:22 +0200 Subject: [PATCH 25/35] QMAPS-1883 fix test --- tests/__data__/autocomplete.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/__data__/autocomplete.json b/tests/__data__/autocomplete.json index 71eb2567d..287816dcd 100644 --- a/tests/__data__/autocomplete.json +++ b/tests/__data__/autocomplete.json @@ -109,8 +109,8 @@ "bbox" : [1,2,3,4], "id": "osm:way:63178753", "type": "poi", - "label": "Musée d'Orsay", - "name": "Musée d'Orsay", + "label": "test", + "name": "test", "postcode": null, "city": null, "citycode": null, From fda3f355a43c6736e22cae4237c73af568202ed3 Mon Sep 17 00:00:00 2001 From: xem Date: Mon, 19 Apr 2021 14:47:30 +0200 Subject: [PATCH 26/35] QMAPS-1883 fix test --- tests/integration/tests/poi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/poi.js b/tests/integration/tests/poi.js index 9c4485122..5c60634f2 100644 --- a/tests/integration/tests/poi.js +++ b/tests/integration/tests/poi.js @@ -97,7 +97,7 @@ test('open poi from autocomplete selection', async () => { }); // url is updated - expect(location.href).toMatch(/osm:way:63178753@Mus%C3%A9e_dOrsay/); + expect(location.href).toMatch(/osm:way:63178753@test/); // poi panel is visible expect(await exists(page, '.poi_panel')).toBeTruthy(); }); From 25f60db78e569b14e515fb71a7fb54e0345b4516 Mon Sep 17 00:00:00 2001 From: xem Date: Mon, 19 Apr 2021 14:58:20 +0200 Subject: [PATCH 27/35] QMAPS-1883 fix test --- tests/__data__/autocomplete.json | 4 ++-- tests/integration/tests/poi.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/__data__/autocomplete.json b/tests/__data__/autocomplete.json index 287816dcd..71eb2567d 100644 --- a/tests/__data__/autocomplete.json +++ b/tests/__data__/autocomplete.json @@ -109,8 +109,8 @@ "bbox" : [1,2,3,4], "id": "osm:way:63178753", "type": "poi", - "label": "test", - "name": "test", + "label": "Musée d'Orsay", + "name": "Musée d'Orsay", "postcode": null, "city": null, "citycode": null, diff --git a/tests/integration/tests/poi.js b/tests/integration/tests/poi.js index 5c60634f2..9c4485122 100644 --- a/tests/integration/tests/poi.js +++ b/tests/integration/tests/poi.js @@ -97,7 +97,7 @@ test('open poi from autocomplete selection', async () => { }); // url is updated - expect(location.href).toMatch(/osm:way:63178753@test/); + expect(location.href).toMatch(/osm:way:63178753@Mus%C3%A9e_dOrsay/); // poi panel is visible expect(await exists(page, '.poi_panel')).toBeTruthy(); }); From 6e394ced43954fe586256114df6031334a55ec71 Mon Sep 17 00:00:00 2001 From: xem Date: Mon, 19 Apr 2021 15:06:07 +0200 Subject: [PATCH 28/35] QMAPS-1883 fix test --- tests/integration/tests/autocomplete.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index f859d5436..e93412225 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -150,8 +150,7 @@ test('mouse navigation', async () => { await autocompleteHelper.clickResult(1); const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - const expectedLabelName = mockAutocomplete.features[0].properties.geocoding.name; - expect(selectedSearchValue).toEqual(expectedLabelName); + expect(selectedSearchValue).toEqual("Musée d'Orsay"); }); test('move to on click', async () => { @@ -250,7 +249,7 @@ test('Search Query', async () => { const searchValue = await getInputValue(page, '#search'); // search input is filled with query - expect(searchValue).toEqual(searchQuery); + expect(searchValue).toEqual("Musée d'Orsay"); // app navigates to first result from autocomplete expect(page.url()).toEqual(`${APP_URL}/place/osm:node:4872758213@test_result_1`); From 9c5a9d18b35d553a883cba7c277e0972be7ca385 Mon Sep 17 00:00:00 2001 From: xem Date: Mon, 19 Apr 2021 15:18:16 +0200 Subject: [PATCH 29/35] QMAPS-1883 fix test --- tests/integration/tests/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index e93412225..c46c787f5 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -150,7 +150,7 @@ test('mouse navigation', async () => { await autocompleteHelper.clickResult(1); const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - expect(selectedSearchValue).toEqual("Musée d'Orsay"); + expect(selectedSearchValue).toEqual('test result 1'); }); test('move to on click', async () => { From c2d68b3192a7925a3be58b933a6f764ffe7d12b6 Mon Sep 17 00:00:00 2001 From: xem Date: Mon, 19 Apr 2021 15:28:27 +0200 Subject: [PATCH 30/35] QMAPS-1883 comment test --- tests/integration/tests/autocomplete.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index c46c787f5..66dcd7813 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -149,8 +149,9 @@ test('mouse navigation', async () => { expect(searchValue.trim()).toEqual(TypedSearch); await autocompleteHelper.clickResult(1); - const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - expect(selectedSearchValue).toEqual('test result 1'); + //const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); + //const expectedLabelName = mockAutocomplete.features[0].properties.geocoding.name; + //expect(selectedSearchValue).toEqual(expectedLabelName); }); test('move to on click', async () => { From 3192910f92e6395c79e82f6400a67e3b2ccce359 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 21 Apr 2021 09:47:23 +0200 Subject: [PATCH 31/35] QMAPS-1883 PR fixes --- src/panel/PanelManager.jsx | 23 +++++++++++------------ src/panel/poi/PoiPanel.jsx | 5 ----- tests/integration/tests/autocomplete.js | 8 ++++---- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/panel/PanelManager.jsx b/src/panel/PanelManager.jsx index fecbf3d60..5017299f2 100644 --- a/src/panel/PanelManager.jsx +++ b/src/panel/PanelManager.jsx @@ -1,4 +1,3 @@ -/* globals _ */ import React from 'react'; import PropTypes from 'prop-types'; import SearchInput from '../ui_components/search_input'; @@ -92,9 +91,12 @@ export default class PanelManager extends React.Component { } } - updateSearchBarContent({ poiFilters = {}, query } = {}) { + updateSearchBarContent({ poiFilters = {}, poi = {}, query } = {}) { const topBarHandle = document.querySelector('.top_bar'); - if (poiFilters.category) { + if (poi.name) { + SearchInput.setInputValue(poi.name); + topBarHandle.classList.add('top_bar--search_filled'); + } else if (poiFilters.category) { const categoryLabel = CategoryService.getCategoryByName(poiFilters.category)?.getInputValue(); SearchInput.setInputValue(categoryLabel); topBarHandle.classList.add('top_bar--search_filled'); @@ -110,10 +112,14 @@ export default class PanelManager extends React.Component { } } - updateTopBarReturnButton({ poiFilters = {} } = {}) { + updateTopBarReturnButton({ poiFilters = {}, isFromFavorite } = {}) { const topBarReturnButton = document.querySelector('.search_form__return-to-list'); const backAction = - poiFilters.category || poiFilters.query ? this.backToList : this.backToFavorite; + poiFilters.category || poiFilters.query + ? this.backToList + : isFromFavorite + ? this.backToFavorite + : () => {}; topBarReturnButton.onclick = e => { backAction(e, poiFilters); }; @@ -202,11 +208,6 @@ export default class PanelManager extends React.Component { const topBarHandle = document.querySelector('.top_bar'); topBarHandle.classList.add('top_bar--poi-from-list'); } - - // Show PoI name in search field - SearchInput.setInputValue(options.poi.name); - const topBarHandle = document.querySelector('.top_bar'); - topBarHandle.classList.add('top_bar--search_filled'); }); router.addRoute('Favorites', '/favs', () => { @@ -215,8 +216,6 @@ export default class PanelManager extends React.Component { options: {}, panelSize: 'default', }); - - SearchInput.setInputValue(_('Favorites', 'search bar')); }); if (directionConf.enabled) { diff --git a/src/panel/poi/PoiPanel.jsx b/src/panel/poi/PoiPanel.jsx index e9649561c..a580774db 100644 --- a/src/panel/poi/PoiPanel.jsx +++ b/src/panel/poi/PoiPanel.jsx @@ -190,11 +190,6 @@ export default class PoiPanel extends React.Component { return null; } - // Ensure PoI name is present in search field - SearchInput.setInputValue(poi.name); - const topBarHandle = document.querySelector('.top_bar'); - topBarHandle.classList.add('top_bar--search_filled'); - const backAction = poiFilters.category || poiFilters.query ? this.props.backToList diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index 66dcd7813..f859d5436 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -149,9 +149,9 @@ test('mouse navigation', async () => { expect(searchValue.trim()).toEqual(TypedSearch); await autocompleteHelper.clickResult(1); - //const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); - //const expectedLabelName = mockAutocomplete.features[0].properties.geocoding.name; - //expect(selectedSearchValue).toEqual(expectedLabelName); + const selectedSearchValue = await autocompleteHelper.getSearchInputValue(); + const expectedLabelName = mockAutocomplete.features[0].properties.geocoding.name; + expect(selectedSearchValue).toEqual(expectedLabelName); }); test('move to on click', async () => { @@ -250,7 +250,7 @@ test('Search Query', async () => { const searchValue = await getInputValue(page, '#search'); // search input is filled with query - expect(searchValue).toEqual("Musée d'Orsay"); + expect(searchValue).toEqual(searchQuery); // app navigates to first result from autocomplete expect(page.url()).toEqual(`${APP_URL}/place/osm:node:4872758213@test_result_1`); From e89cc51e6d64eacfbe0d46e58d9d2ec351c95b47 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 21 Apr 2021 09:52:50 +0200 Subject: [PATCH 32/35] QMAPS-1883 PR fixes --- src/panel/poi/PoiPanel.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/panel/poi/PoiPanel.jsx b/src/panel/poi/PoiPanel.jsx index a580774db..6b82e6101 100644 --- a/src/panel/poi/PoiPanel.jsx +++ b/src/panel/poi/PoiPanel.jsx @@ -19,7 +19,6 @@ import { isNullOrEmpty } from 'src/libs/object'; import { DeviceContext } from 'src/libs/device'; import { Flex, Panel, PanelNav, Divider, Button } from 'src/components/ui'; import { BackToQwantButton } from 'src/components/BackToQwantButton'; -import SearchInput from '../../ui_components/search_input'; const covid19Enabled = (nconf.get().covid19 || {}).enabled; From d9145502253d50457c09725deeda75539a0a2590 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 21 Apr 2021 10:21:50 +0200 Subject: [PATCH 33/35] QMAPS-1883 PR fixes --- tests/integration/tests/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index f859d5436..72ab9b3d1 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -250,7 +250,7 @@ test('Search Query', async () => { const searchValue = await getInputValue(page, '#search'); // search input is filled with query - expect(searchValue).toEqual(searchQuery); + expect(searchValue).toEqual('test result 1'); // app navigates to first result from autocomplete expect(page.url()).toEqual(`${APP_URL}/place/osm:node:4872758213@test_result_1`); From 7d842ef2c70596114b8092571f9d16d89b5f3030 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 21 Apr 2021 11:39:04 +0200 Subject: [PATCH 34/35] QMAPS-1883 PR fixes --- src/panel/PanelManager.jsx | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/panel/PanelManager.jsx b/src/panel/PanelManager.jsx index 5017299f2..7810a8136 100644 --- a/src/panel/PanelManager.jsx +++ b/src/panel/PanelManager.jsx @@ -112,7 +112,7 @@ export default class PanelManager extends React.Component { } } - updateTopBarReturnButton({ poiFilters = {}, isFromFavorite } = {}) { + updateTopBarReturnButton({ poiFilters = {}, isFromFavorite, poi = {} } = {}) { const topBarReturnButton = document.querySelector('.search_form__return-to-list'); const backAction = poiFilters.category || poiFilters.query @@ -123,12 +123,18 @@ export default class PanelManager extends React.Component { topBarReturnButton.onclick = e => { backAction(e, poiFilters); }; - } - // Hide return arrow on mobile - hideReturnButton() { const topBarHandle = document.querySelector('.top_bar'); - topBarHandle.classList.remove('top_bar--poi-from-list'); + + // Show return arrow (on mobile) if user comes from PoI / favorites list + if (poi.name && (poiFilters.category || poiFilters.query || isFromFavorite)) { + topBarHandle.classList.add('top_bar--poi-from-list'); + } + // Hide return button when not on a POI anymore + else { + const topBarHandle = document.querySelector('.top_bar'); + topBarHandle.classList.remove('top_bar--poi-from-list'); + } } backToList(e, poiFilters) { @@ -177,7 +183,6 @@ export default class PanelManager extends React.Component { }, panelSize: 'default', }); - this.hideReturnButton(); }); router.addRoute('noresult', '/noresult', (_, options) => { @@ -186,7 +191,6 @@ export default class PanelManager extends React.Component { panelSize: 'default', options: { ...options }, }); - this.hideReturnButton(); }); router.addRoute('POI', '/place/([^?]+)', async (poiUrl, options = {}) => { @@ -201,13 +205,6 @@ export default class PanelManager extends React.Component { }, panelSize: 'default', }); - - // Show return arrow (on mobile) if user comes from PoI / favorites list - const { poiFilters = {}, isFromFavorite } = options; - if (poiFilters.category || poiFilters.query || isFromFavorite) { - const topBarHandle = document.querySelector('.top_bar'); - topBarHandle.classList.add('top_bar--poi-from-list'); - } }); router.addRoute('Favorites', '/favs', () => { @@ -232,7 +229,6 @@ export default class PanelManager extends React.Component { options: { ...params, ...options, isPublicTransportActive }, panelSize: 'default', }); - this.hideReturnButton(); }); } @@ -243,7 +239,6 @@ export default class PanelManager extends React.Component { } else { router.routeUrl('/'); } - this.hideReturnButton(); }); // Default matching route @@ -256,7 +251,6 @@ export default class PanelManager extends React.Component { if (options?.focusSearch) { SearchInput.select(); } - this.hideReturnButton(); }); // Route the initial URL From 3151aba0231fdf5b57610f67df4b1dc355013137 Mon Sep 17 00:00:00 2001 From: xem Date: Wed, 21 Apr 2021 18:10:49 +0200 Subject: [PATCH 35/35] QMAPS-1883 comment --- tests/integration/tests/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tests/autocomplete.js b/tests/integration/tests/autocomplete.js index 72ab9b3d1..e9567ad8a 100644 --- a/tests/integration/tests/autocomplete.js +++ b/tests/integration/tests/autocomplete.js @@ -249,7 +249,7 @@ test('Search Query', async () => { await page.goto(`${APP_URL}/?q=${searchQuery}`); const searchValue = await getInputValue(page, '#search'); - // search input is filled with query + // search input is filled with PoI name (not the query) expect(searchValue).toEqual('test result 1'); // app navigates to first result from autocomplete