further fleshing out of find display to support Prev and Next buttons
This commit is contained in:
@@ -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)",
|
||||
offset*listMax+1, offset*listMax+len(commList), numComm))
|
||||
ctxt.VarMap().Set("resultList", commList)
|
||||
ctxt.VarMap().Set("resultFromDirectory", true)
|
||||
if offset > 0 {
|
||||
ctxt.VarMap().Set("resultShowPrev", true)
|
||||
}
|
||||
@@ -113,6 +114,7 @@ func FindPage(ctxt ui.AmContext) (string, any, error) {
|
||||
}
|
||||
ctxt.SetSession("find.mode", mode)
|
||||
ctxt.VarMap().Set("mode", mode)
|
||||
ctxt.VarMap().Set("ofs", ofs)
|
||||
switch mode {
|
||||
case "COM":
|
||||
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("term", "")
|
||||
case "CAT":
|
||||
ctxt.VarMap().Set("field", "name")
|
||||
ctxt.VarMap().Set("oper", "st")
|
||||
ctxt.VarMap().Set("term", "")
|
||||
case "PST":
|
||||
ctxt.VarMap().Set("field", "name")
|
||||
ctxt.VarMap().Set("oper", "in")
|
||||
ctxt.VarMap().Set("term", "")
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -12,6 +12,7 @@ package ui
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
@@ -90,7 +91,7 @@ func makeYearRange(a jet.Arguments) reflect.Value {
|
||||
return reflect.ValueOf(err)
|
||||
}
|
||||
} 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
@@ -45,9 +45,6 @@
|
||||
<form method="POST" action="/find">
|
||||
<input type="hidden" name="mode" value="{{ mode }}">
|
||||
<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">
|
||||
{{ if mode == "COM" }}
|
||||
@@ -127,8 +124,7 @@
|
||||
|
||||
<!-- Search Button -->
|
||||
<div>
|
||||
<button type="submit"
|
||||
name="search"
|
||||
<button type="submit" name="search"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white px-8 py-2 rounded font-medium transition-colors">
|
||||
Search
|
||||
</button>
|
||||
@@ -231,6 +227,43 @@
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</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>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user