further fleshing out of find display to support Prev and Next buttons

This commit is contained in:
2025-10-20 22:47:39 -06:00
parent e6f157c337
commit 7e3b1d535f
3 changed files with 45 additions and 6 deletions
+5
View File
@@ -70,6 +70,7 @@ func loadCategoryInformation(ctxt ui.AmContext, offset int) error {
ctxt.VarMap().Set("resultHeader", fmt.Sprintf("Communities in Category (Displaying %d-%d of %d)", ctxt.VarMap().Set("resultHeader", fmt.Sprintf("Communities in Category (Displaying %d-%d of %d)",
offset*listMax+1, offset*listMax+len(commList), numComm)) offset*listMax+1, offset*listMax+len(commList), numComm))
ctxt.VarMap().Set("resultList", commList) ctxt.VarMap().Set("resultList", commList)
ctxt.VarMap().Set("resultFromDirectory", true)
if offset > 0 { if offset > 0 {
ctxt.VarMap().Set("resultShowPrev", true) ctxt.VarMap().Set("resultShowPrev", true)
} }
@@ -113,6 +114,7 @@ func FindPage(ctxt ui.AmContext) (string, any, error) {
} }
ctxt.SetSession("find.mode", mode) ctxt.SetSession("find.mode", mode)
ctxt.VarMap().Set("mode", mode) ctxt.VarMap().Set("mode", mode)
ctxt.VarMap().Set("ofs", ofs)
switch mode { switch mode {
case "COM": case "COM":
ctxt.VarMap().Set("field", "name") ctxt.VarMap().Set("field", "name")
@@ -127,9 +129,12 @@ func FindPage(ctxt ui.AmContext) (string, any, error) {
ctxt.VarMap().Set("oper", "st") ctxt.VarMap().Set("oper", "st")
ctxt.VarMap().Set("term", "") ctxt.VarMap().Set("term", "")
case "CAT": case "CAT":
ctxt.VarMap().Set("field", "name")
ctxt.VarMap().Set("oper", "st") ctxt.VarMap().Set("oper", "st")
ctxt.VarMap().Set("term", "") ctxt.VarMap().Set("term", "")
case "PST": case "PST":
ctxt.VarMap().Set("field", "name")
ctxt.VarMap().Set("oper", "in")
ctxt.VarMap().Set("term", "") ctxt.VarMap().Set("term", "")
} }
+2 -1
View File
@@ -12,6 +12,7 @@ package ui
import ( import (
"embed" "embed"
"errors"
"fmt" "fmt"
"io" "io"
"reflect" "reflect"
@@ -90,7 +91,7 @@ func makeYearRange(a jet.Arguments) reflect.Value {
return reflect.ValueOf(err) return reflect.ValueOf(err)
} }
} else { } else {
return reflect.ValueOf(fmt.Errorf("cannot locate year: marker in param")) return reflect.ValueOf(errors.New("cannot locate year: marker in param"))
} }
} }
+38 -5
View File
@@ -45,9 +45,6 @@
<form method="POST" action="/find"> <form method="POST" action="/find">
<input type="hidden" name="mode" value="{{ mode }}"> <input type="hidden" name="mode" value="{{ mode }}">
<input type="hidden" name="ofs" value="0"> <input type="hidden" name="ofs" value="0">
{{ if mode == "COM" }}
<input type="hidden" name="catid" value="{{ catid }}">
{{ end }}
<div class="bg-gray-50 p-6 rounded-lg"> <div class="bg-gray-50 p-6 rounded-lg">
{{ if mode == "COM" }} {{ if mode == "COM" }}
@@ -127,8 +124,7 @@
<!-- Search Button --> <!-- Search Button -->
<div> <div>
<button type="submit" <button type="submit" name="search"
name="search"
class="bg-blue-600 hover:bg-blue-700 text-white px-8 py-2 rounded font-medium transition-colors"> class="bg-blue-600 hover:bg-blue-700 text-white px-8 py-2 rounded font-medium transition-colors">
Search Search
</button> </button>
@@ -231,6 +227,43 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
</div> </div>
{{ if isset(resultShowPrev) || isset(resultShowNext) }}
<div class="flex justify-center gap-4 mt-6">
{{ if isset(resultFromDirectory) }}
{{ if isset(resultShowPrev) }}
<a href="/find?mode=COM&catid={{ catid }}&ofs={{ ofs - 1 }}"
class="inline-block bg-blue-600 hover:bg-blue-700 text-white px-4 py-1 rounded text-xs font-medium transition-colors">
⏪ Prev
</a>
{{ end }}
{{ if isset(resultShowNext) }}
<a href="/find?mode=COM&catid={{ catid }}&ofs={{ ofs + 1 }}"
class="inline-block bg-blue-600 hover:bg-blue-700 text-white px-4 py-1 rounded text-xs font-medium transition-colors">
Next ⏩
</a>
{{ end }}
{{ else }}
<form method="POST" action="/find">
<input type="hidden" name="mode" value="{{ mode }}"/>
<input type="hidden" name="ofs" value="{{ ofs }}"/>
<input type="hidden" name="field" value="{{ field }}"/>
<input type="hidden" name="oper" value="{{ oper }}"/>
<input type="hidden" name="term" value="{{ term }}"/>
{{ if isset(resultShowPrev) }}
<button type="submit" name="prev"
class="bg-blue-600 hover:bg-blue-700 text-white px-8 py-2 rounded font-medium transition-colors">
⏪ Prev
</button>
{{ if isset(resultShowNext) }}
<button type="submit" name="next"
class="bg-blue-600 hover:bg-blue-700 text-white px-8 py-2 rounded font-medium transition-colors">
Next ⏩
</button>
{{ end }}
</form>
{{ end }}
</div>
{{ end }}
</div> </div>
{{ end }} {{ end }}
{{ end }} {{ end }}