commit 1a3556679b0493b762e7c9d8d728c7644d02fa35
parent bc8b91a3249c4d4888f4b728aa65ed0bba308e03
Author: Milan Pässler <milan@petabyte.dev>
Date: Fri, 18 Sep 2020 21:13:48 +0200
parent bc8b91a3249c4d4888f4b728aa65ed0bba308e03
Author: Milan Pässler <milan@petabyte.dev>
Date: Fri, 18 Sep 2020 21:13:48 +0200
explicitly handle empty via
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/client/js/languages.js b/client/js/languages.js @@ -7,6 +7,7 @@ export const languages = { 'products': 'Produkte', 'from': 'Von', 'via': 'Über', + 'optional': '(optional)', 'to': 'Nach', 'date': 'Datum', 'time': 'Uhrzeit', @@ -61,6 +62,7 @@ export const languages = { 'products': 'Products', 'from': 'From', 'via': 'Via', + 'optional': '(optional)', 'to': 'To', 'date': 'Date', 'time': 'Time',
diff --git a/client/js/searchView.js b/client/js/searchView.js @@ -35,7 +35,7 @@ const searchTemplate = (journeysHistory) => html` <div class="suggestions" id="fromSuggestions"></div> <label for="via">${t('via')}:</label> - <input type="text" name="via" id="via" placeholder="${t('via')}" value="${viaValue}" autocomplete="off" @focus=${startTyping} @blur=${stopTyping} @keyup=${onKeyup} @keydown=${onKeydown} required> + <input type="text" name="via" id="via" placeholder="${t('via')} ${t('optional')}" value="${viaValue}" autocomplete="off" @focus=${startTyping} @blur=${stopTyping} @keyup=${onKeyup} @keydown=${onKeydown} required> <div class="suggestions" id="viaSuggestions"></div> <label for="to">${t('to')}:</label> @@ -237,7 +237,9 @@ export const search = async (requestId) => { from = suggestions[0] } - if (Object.entries(suggestionsCache.via).length !== 0) { + if (ElementById('via').value == "") { + via = null; + } else if (Object.entries(suggestionsCache.via).length !== 0) { via = suggestionsCache.via; } else { let suggestions = await get("/suggestions", {"query": ElementById('via').value, "results": 1}, true); @@ -277,12 +279,13 @@ export const search = async (requestId) => { let params = { "fromPoint": from, - "viaPoint": via, "toPoint": to, "accessibility": accessibility, "products": products } + if (via !== null) params.viaPoint = via; + if (!isDep) { params.arrival = timestamp } else {