aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-01-22 11:12:49 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-01-22 11:12:49 +0100
commite1bce1b772c3a6e4e09b6ad43298617399b9438f (patch)
treefec6e05ddc4fb329822f2984603f38a52f9c688f
parent845a82d8d661e26d188f7a420de04e538323ae92 (diff)
downloadoeffi-web-e1bce1b772c3a6e4e09b6ad43298617399b9438f.tar.gz
oeffi-web-e1bce1b772c3a6e4e09b6ad43298617399b9438f.tar.bz2
oeffi-web-e1bce1b772c3a6e4e09b6ad43298617399b9438f.zip
searchView: set from/to via queryString
-rw-r--r--src/endpoints/searchHandler.nim6
-rw-r--r--templates/journeys.tpl2
-rw-r--r--templates/search.tpl4
3 files changed, 7 insertions, 5 deletions
diff --git a/src/endpoints/searchHandler.nim b/src/endpoints/searchHandler.nim
index 72c93a1..24689bb 100644
--- 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
index be2ad39..f322502 100644
--- 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
index 26bf137..b3281b0 100644
--- 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>