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', 'products': 'Produkte',
'from': 'Von', 'from': 'Von',
'via': 'Über', 'via': 'Über',
'optional': '(optional)',
'to': 'Nach', 'to': 'Nach',
'date': 'Datum', 'date': 'Datum',
'time': 'Uhrzeit', 'time': 'Uhrzeit',
@ -61,6 +62,7 @@ export const languages = {
'products': 'Products', 'products': 'Products',
'from': 'From', 'from': 'From',
'via': 'Via', 'via': 'Via',
'optional': '(optional)',
'to': 'To', 'to': 'To',
'date': 'Date', 'date': 'Date',
'time': 'Time', 'time': 'Time',

View file

@ -35,7 +35,7 @@ const searchTemplate = (journeysHistory) => html`
<div class="suggestions" id="fromSuggestions"></div> <div class="suggestions" id="fromSuggestions"></div>
<label for="via">${t('via')}:</label> <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> <div class="suggestions" id="viaSuggestions"></div>
<label for="to">${t('to')}:</label> <label for="to">${t('to')}:</label>
@ -237,7 +237,9 @@ export const search = async (requestId) => {
from = suggestions[0] 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; via = suggestionsCache.via;
} else { } else {
let suggestions = await get("/suggestions", {"query": ElementById('via').value, "results": 1}, true); let suggestions = await get("/suggestions", {"query": ElementById('via').value, "results": 1}, true);
@ -277,12 +279,13 @@ export const search = async (requestId) => {
let params = { let params = {
"fromPoint": from, "fromPoint": from,
"viaPoint": via,
"toPoint": to, "toPoint": to,
"accessibility": accessibility, "accessibility": accessibility,
"products": products "products": products
} }
if (via !== null) params.viaPoint = via;
if (!isDep) { if (!isDep) {
params.arrival = timestamp params.arrival = timestamp
} else { } else {