summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--components/recommendation.html48
-rw-r--r--internal/handlers/elements.go18
-rw-r--r--internal/server/router.go2
3 files changed, 68 insertions, 0 deletions
diff --git a/components/recommendation.html b/components/recommendation.html
new file mode 100644
index 0000000..5036088
--- /dev/null
+++ b/components/recommendation.html
@@ -0,0 +1,48 @@
+{{define "recommentdation"}}
+<div class="actiontable">
+<p>ActionTypePlus</p>
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Magnitude</th>
+ <th>Repeatable</th>
+ <th>Commit</th>
+ </tr>
+ {{range $action := .Actions}}
+ {{if and (eq $action.Type "ActionTypePlus") (or (not $action.Done) ($action.Repeatable))}}
+ <form hx-post="/done" hx-target="#ancestor" hx-swap="outerHTML">
+ <tr>
+ <td><input class="action_name" name="name" value={{$action.Name}} type="hidden" readonly />{{$action.Name}}</td>
+ <td>{{$action.Magnitude}}</td>
+ <td>{{$action.Repeatable}}</td>
+ <td><input type="submit" value="Done It"></input></td>
+ </tr>
+ </form>
+ {{end}}
+ {{end}}
+</table>
+</div>
+<div class="actiontable">
+<p>ActionTypeMinus</p>
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Magnitude</th>
+ <th>Repeatable</th>
+ <th>Commit</th>
+ </tr>
+ {{range $action := .Actions}}
+ {{if eq $action.Type "ActionTypeMinus"}}
+ <form hx-post="/done" hx-target="#ancestor" hx-swap="outerHTML">
+ <tr>
+ <td><input class="action_name" name="name" value={{$action.Name}} type="hidden" readonly />{{$action.Name}}</td>
+ <td>{{$action.Magnitude}}</td>
+ <td>{{$action.Repeatable}}</td>
+ <td><input type="submit" value="Done It"></input></td>
+ </tr>
+ </form>
+ {{end}}
+ {{end}}
+</table>
+</div>
+{{end}}
diff --git a/internal/handlers/elements.go b/internal/handlers/elements.go
index 62c632b..965281a 100644
--- a/internal/handlers/elements.go
+++ b/internal/handlers/elements.go
@@ -22,3 +22,21 @@ func (h *Handlers) ServeHideForm(w http.ResponseWriter, r *http.Request) {
}
tmpl.ExecuteTemplate(w, "showformbtn", nil)
}
+
+func (h *Handlers) ShowRecommended(w http.ResponseWriter, r *http.Request) {
+ tmpl, err := template.ParseGlob("components/*.html")
+ if err != nil {
+ abortWithError(w, err.Error())
+ return
+ }
+ tmpl.ExecuteTemplate(w, "showformbtn", nil)
+}
+
+func (h *Handlers) HideRecommended(w http.ResponseWriter, r *http.Request) {
+ tmpl, err := template.ParseGlob("components/*.html")
+ if err != nil {
+ abortWithError(w, err.Error())
+ return
+ }
+ tmpl.ExecuteTemplate(w, "showformbtn", nil)
+}
diff --git a/internal/server/router.go b/internal/server/router.go
index ae68418..f36e55f 100644
--- a/internal/server/router.go
+++ b/internal/server/router.go
@@ -29,6 +29,8 @@ func (srv *server) ListenToRequests() {
// ====== elements ======
mux.HandleFunc("GET /showform", h.ServeShowForm)
mux.HandleFunc("GET /hideform", h.ServeHideForm)
+ mux.HandleFunc("GET /recommendation", h.ShowRecommended)
+ mux.HandleFunc("GET /recommendation-hide", h.HideRecommended)
fmt.Printf("Listening on %v\n", server.Addr)
server.ListenAndServe()