explicitly handle empty via

This commit is contained in:
Milan Pässler 2020-09-18 21:13:48 +02:00
parent bc8b91a324
commit 1a3556679b
2 changed files with 8 additions and 3 deletions

View file

@ -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',

View file

@ -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 {