Enable editing of titles
This commit is contained in:
parent
e2c59d5f28
commit
fd8e140897
2 changed files with 12 additions and 2 deletions
|
|
@ -80,10 +80,17 @@ func delete(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func save(w http.ResponseWriter, r *http.Request) {
|
||||
title := r.PathValue("note")
|
||||
oldTitle := r.PathValue("note")
|
||||
title := r.FormValue("title")
|
||||
body := r.FormValue("body")
|
||||
|
||||
note := ¬es.Note{Title: title, Body: []byte(body)}
|
||||
note.Save()
|
||||
|
||||
if oldTitle != title {
|
||||
notes.DeleteNote(oldTitle)
|
||||
}
|
||||
|
||||
http.Redirect(w, r, myurls.Reverse("view", urls.Repl{"note": title}), http.StatusFound)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@
|
|||
{{define "main"}}
|
||||
<form action="{{.urlSave}}" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="noteBodyInput" class="form-label">Note</label>
|
||||
<input type="text" class="form-control" id="noteTitleInput" name="title" aria-described-by="titleHelp" value="{{.note.Title}}"/>
|
||||
<div id="titleHelp" class="form-text">Enter your note title</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="border rounded rounded-1">
|
||||
<div id="toolbar"></div>
|
||||
<textarea class="form-control" id="noteBodyInput" name="body" aria-described-by="bodyHelp">{{.text}}</textarea>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue