From b96600e2bb06e086282ffc8a2447c682569961b2 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 28 Sep 2024 03:34:54 +0200 Subject: added ui changes - Added a delete button next to each idea instead of deleting them by name - Changed Post to Think - Added a text when there are no ideas - Added more CSS for the create - Added checks for denying empty fields --- ideas.html | 41 ++++++++++++++++++++++++++++++++--------- main.go | 9 +++++++-- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/ideas.html b/ideas.html index 89cb4bc..3b110c3 100644 --- a/ideas.html +++ b/ideas.html @@ -6,6 +6,9 @@ Ideas @@ -48,16 +68,13 @@ {{ with .Error }}

{{.}}

{{ end}} +

Add an idea:

-
-
-
- -
-
-
-
- +
+ +
+
+

diff --git a/main.go b/main.go index 1077ea9..8bd2d5c 100644 --- a/main.go +++ b/main.go @@ -30,12 +30,13 @@ var ideas_html string var Ideas []Idea // ToDo's -// - [ ] Add a post -// - [ ] Remove a post +// - [x] Add a post +// - [x] Remove a post // - [ ] work with funcmaps in templates // - [ ] Put a reaction on a post // - [x] Store ideas to a file (encoder/gob) // - [x] Change the date format printing +// - [x] outsource removing the posts to a separate cli tool // Represents an idea // CreatedAt is a formatted date string @@ -166,6 +167,10 @@ func main() { CreatedAt: time.Now().Format(DateLayout), Text: r.FormValue("text"), } + if i.Title == "" || i.Author == "" || i.Text == "" { + tmpl.Execute(w, PageData{Ideas, "All fields are required"}) + return + } for _, v := range Ideas { if i.Title == v.Title { -- cgit v1.2.3