summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2021-02-23 17:37:08 -0500
committerAdam T. Carpenter <atc@53hor.net>2021-02-23 17:37:08 -0500
commit1259dad8d561bd390262314035d5252905d1c12e (patch)
treefb560349dfa27f8eb48fa76daa9cba90695d6540 /src
parent76da278e446e06731ff0676778fa3c960238070e (diff)
downloadtwinh-1259dad8d561bd390262314035d5252905d1c12e.tar.xz
twinh-1259dad8d561bd390262314035d5252905d1c12e.zip
basic make/model/parts list flow functional
Diffstat (limited to 'src')
-rw-r--r--src/main.rs1
-rw-r--r--src/templates/index.html41
2 files changed, 20 insertions, 22 deletions
diff --git a/src/main.rs b/src/main.rs
index 6947482..2f5bdf4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -39,7 +39,6 @@ async fn router(req: Request<Body>) -> Result<Response<Body>, Infallible> {
async fn parts(req: Request<Body>) -> Result<Response<Body>, Infallible> {
let query = req.uri().query().unwrap_or_default();
let filter = serde_urlencoded::de::from_str::<PartsRequest>(query).unwrap();
- dbg!(&query, &filter);
let mut reg = Handlebars::new();
reg.register_template_string("index", templates::INDEX_T)
.unwrap();
diff --git a/src/templates/index.html b/src/templates/index.html
index 6b2f54a..683891c 100644
--- a/src/templates/index.html
+++ b/src/templates/index.html
@@ -11,28 +11,27 @@
</head>
<body>
<h1>Parts Catalog</h1>
+ {{#each makes}}
<form action="/parts">
- <ul>
- {{#each makes}}
- <li>
- <input type="submit" name="make" value="{{ this }}" />
- {{#if (eq this "Hudson")}}
- <ul>
- <input type="hidden" name="make" value="{{ selected_make }}" />
- {{#each models}}
- <li>
- <input type="submit" name="model" value="{{ this }}" />
- </li>
- {{else}}
- No models found.
- {{/each}}
- </ul>
- {{/if}}
- </li>
- {{else}}
- No makes found.
- {{/each}}
- </ul>
+ {{#if (eq this ../selected_make)}}
+ <input disabled type="submit" name="make" value="{{ this }}" />
+ <input type="hidden" name="make" value="{{ ../selected_make }}" />
+ {{#each ../models}}
+ {{#if (eq this ../../selected_model)}}
+ <input disabled type="submit" name="model" value="{{ this }}" />
+ Parts for {{ this }}
+ {{else}}
+ <input type="submit" name="model" value="{{ this }}" />
+ {{/if}}
+ {{else}}
+ No models found.
+ {{/each}}
+ {{else}}
+ <input type="submit" name="make" value="{{ this }}" />
+ {{/if}}
</form>
+ {{else}}
+ No makes found.
+ {{/each}}
</body>
</html>