From 574fd098228f5b63d10a4a739ee7b8e6c668a671 Mon Sep 17 00:00:00 2001
From: Thomas Voss <mail@thomasvoss.com>
Date: Sun, 11 Aug 2024 22:33:34 +0200
Subject: More work on mintages

---
 template/coins_mintages.templ | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

(limited to 'template')

diff --git a/template/coins_mintages.templ b/template/coins_mintages.templ
index b6ed2de..47940e1 100644
--- a/template/coins_mintages.templ
+++ b/template/coins_mintages.templ
@@ -17,7 +17,7 @@ var denoms = [...]float64{
 templ CoinsMintages() {
 	{{
 		code := ctx.Value("code").(string)
-		set := ctx.Value("set").(mintage.Set)
+		table := ctx.Value("table").([]mintage.Row)
 		p := ctx.Value("printer").(lib.Printer)
 	}}
 	<header>
@@ -45,7 +45,7 @@ templ CoinsMintages() {
 				<div class="grid">
 					<label for="country-dd">
 						{ p.T("Country") }
-						<select id="country-dd" name="c">
+						<select id="country-dd" name="code">
 							for _, c := range ctx.Value("countries").
 								([]lib.Country) {
 								<option
@@ -58,18 +58,9 @@ templ CoinsMintages() {
 						</select>
 					</label>
 					<fieldset>
-						<label for="compact-circ">
-							<input id="compact-circ" type="checkbox" name="circ" checked/>
-							{ p.T("Circulation Coins") }
-						</label>
-						<label for="compact-nifc">
-							<input id="compact-nifc" type="checkbox" name="nifc"/>
-							{ p.T("NIFC / BU Sets") }
-						</label>
-						<label for="compact-proof">
-							<input id="compact-proof" type="checkbox" name="proof"/>
-							{ p.T("Proof Coins") }
-						</label>
+						@coinTypeRadio("circ", p.T("Circulation Coins"))
+						@coinTypeRadio("nifc", p.T("NIFC / BU Sets"))
+						@coinTypeRadio("proof", p.T("Proof Coins"))
 					</fieldset>
 				</div>
 				<button type="submit">{ p.T("Filter") }</button>
@@ -83,7 +74,7 @@ templ CoinsMintages() {
 						}
 					</thead>
 					<tbody>
-						for _, row := range set.Circ {
+						for _, row := range table {
 							<tr>
 								<th scope="col">
 									if row.Mintmark != "" {
@@ -110,3 +101,16 @@ templ CoinsMintages() {
 		</section>
 	</main>
 }
+
+templ coinTypeRadio(short, long string) {
+	<label for={ "compact-" + short }>
+		<input
+			id={ "compact-" + short }
+			type="radio"
+			name="type"
+			value={ short }
+			checked?={ ctx.Value("type").(string) == short }
+		/>
+		{ long }
+	</label>
+}
-- 
cgit v1.2.3