commit e1bce1b772c3a6e4e09b6ad43298617399b9438f
parent 845a82d8d661e26d188f7a420de04e538323ae92
Author: Leah (ctucx) <leah@ctu.cx>
Date: Fri, 22 Jan 2021 11:12:49 +0100
parent 845a82d8d661e26d188f7a420de04e538323ae92
Author: Leah (ctucx) <leah@ctu.cx>
Date: Fri, 22 Jan 2021 11:12:49 +0100
searchView: set from/to via queryString
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/endpoints/searchHandler.nim b/src/endpoints/searchHandler.nim @@ -12,8 +12,10 @@ proc searchHandler* (request: Request, server: ServerRef) {.async.} = languageHandler() var templateContext = %* { - "DATE": now().format("yyyy-MM-dd"), - "TIME": now().format("HH:mm") + "DATE": now().format("yyyy-MM-dd"), + "TIME": now().format("HH:mm"), + "FROM": if requestParams.contains("from"): requestParams["from"] else: "", + "TO": if requestParams.contains("to"): requestParams["to"] else: "" } await request.respTemplate(Http200, "search", templateContext, lang, headers)
diff --git a/templates/journeys.tpl b/templates/journeys.tpl @@ -17,7 +17,7 @@ </head> <body class="journeys"> <header> - <a class="back" href="/" title="{{LABEL_BACK}}">{{LABEL_BACK}}</a> + <a class="back" href="/?from={{FROM}}&to={{TO}}" title="{{LABEL_BACK}}">{{LABEL_BACK}}</a> <h3>{{LABEL_FROM}}: {{FROM}}</h3> <h3>{{LABEL_TO}}: {{TO}}</h3> </header>
diff --git a/templates/search.tpl b/templates/search.tpl @@ -24,7 +24,7 @@ <div class="input-group"> <label for="from">{{LABEL_FROM}}:</label> - <input type="text" name="from" id="from" placeholder="{{LABEL_FROM}}" autocomplete="off" required> + <input type="text" name="from" id="from" placeholder="{{LABEL_FROM}}" autocomplete="off" value="{{FROM}}" required> <div class="suggestions" id="fromSuggestions"></div> <label for="via">{{LABEL_VIA}} ({{LABEL_OPTIONAL}}):</label> @@ -32,7 +32,7 @@ <div class="suggestions" id="viaSuggestions"></div> <label for="to">{{LABEL_TO}}:</label> - <input type="text" name="to" id="to" placeholder="{{LABEL_TO}}" autocomplete="off" required> + <input type="text" name="to" id="to" placeholder="{{LABEL_TO}}" autocomplete="off" value="{{TO}}" required> <div class="suggestions" id="toSuggestions"></div> </div>