From 968b835d0e6fe960c3d7ab915ef6d9cecec4ab7f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 5 Aug 2024 02:33:54 +0900 Subject: feat(backend): allow to edit `game_type` in admin page --- backend/admin/handlers.go | 4 ++++ backend/admin/templates/game_edit.html | 13 ++++++++++--- backend/admin/templates/games.html | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'backend/admin') diff --git a/backend/admin/handlers.go b/backend/admin/handlers.go index 14523e6..d9a6977 100644 --- a/backend/admin/handlers.go +++ b/backend/admin/handlers.go @@ -130,6 +130,7 @@ func (h *AdminHandler) getGames(c echo.Context) error { } games[i] = echo.Map{ "GameID": g.GameID, + "GameType": g.GameType, "State": g.State, "DisplayName": g.DisplayName, "DurationSeconds": g.DurationSeconds, @@ -167,6 +168,7 @@ func (h *AdminHandler) getGameEdit(c echo.Context) error { "Title": "Game Edit", "Game": echo.Map{ "GameID": row.GameID, + "GameType": row.GameType, "State": row.State, "DisplayName": row.DisplayName, "DurationSeconds": row.DurationSeconds, @@ -190,6 +192,7 @@ func (h *AdminHandler) postGameEdit(c echo.Context) error { } } + gameType := c.FormValue("game_type") state := c.FormValue("state") displayName := c.FormValue("display_name") durationSeconds, err := strconv.Atoi(c.FormValue("duration_seconds")) @@ -247,6 +250,7 @@ func (h *AdminHandler) postGameEdit(c echo.Context) error { err = h.q.UpdateGame(c.Request().Context(), db.UpdateGameParams{ GameID: int32(gameID), + GameType: gameType, State: state, DisplayName: displayName, DurationSeconds: int32(durationSeconds), diff --git a/backend/admin/templates/game_edit.html b/backend/admin/templates/game_edit.html index 8bc5410..764b577 100644 --- a/backend/admin/templates/game_edit.html +++ b/backend/admin/templates/game_edit.html @@ -14,12 +14,19 @@ +
+ + +
- - - + + diff --git a/backend/admin/templates/games.html b/backend/admin/templates/games.html index 244fc94..47dc4a3 100644 --- a/backend/admin/templates/games.html +++ b/backend/admin/templates/games.html @@ -9,7 +9,7 @@ {{ range .Games }}
  • - {{ .DisplayName }} (id={{ .GameID }}) + {{ .DisplayName }} (id={{ .GameID }} type={{ .GameType }} state={{ .State }})
  • {{ end }} -- cgit v1.2.3-70-g09d2