Added ability to view tags when rejecting and change tags when reworking articles
This commit is contained in:
parent
c45df4bf1a
commit
450dd79e51
@ -155,6 +155,12 @@ func ShowRejectedArticles(db *model.DB, s *control.CookieStore) http.HandlerFunc
|
||||
|
||||
func ReviewUnpublishedArticle(db *model.DB, s *control.CookieStore) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
type htmlData struct {
|
||||
Article *model.Article
|
||||
Tags []*model.Tag
|
||||
}
|
||||
data := new(htmlData)
|
||||
|
||||
id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@ -162,21 +168,35 @@ func ReviewUnpublishedArticle(db *model.DB, s *control.CookieStore) http.Handler
|
||||
return
|
||||
}
|
||||
|
||||
article, err := db.GetArticle(id)
|
||||
data.Article, err = db.GetArticle(id)
|
||||
if err != nil {
|
||||
tmpl, err := template.ParseFiles("web/templates/to-be-published.html")
|
||||
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", article)
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
data.Tags, err = db.GetArticleTags(id)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
tmpl, err := template.ParseFiles("web/templates/to-be-published.html")
|
||||
tmpl = template.Must(tmpl, err)
|
||||
tmpl.ExecuteTemplate(w, "page-content", article)
|
||||
tmpl.ExecuteTemplate(w, "page-content", data)
|
||||
}
|
||||
}
|
||||
|
||||
func ReviewRejectedArticle(db *model.DB, s *control.CookieStore) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
type htmlData struct {
|
||||
Selected map[int64]bool
|
||||
Article *model.Article
|
||||
Tags []*model.Tag
|
||||
}
|
||||
data := new(htmlData)
|
||||
|
||||
id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@ -184,16 +204,34 @@ func ReviewRejectedArticle(db *model.DB, s *control.CookieStore) http.HandlerFun
|
||||
return
|
||||
}
|
||||
|
||||
article, err := db.GetArticle(id)
|
||||
data.Article, err = db.GetArticle(id)
|
||||
if err != nil {
|
||||
tmpl, err := template.ParseFiles("web/templates/to-be-published.html")
|
||||
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", article)
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
data.Tags, err = db.GetTagList()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
selectedTags, err := db.GetArticleTags(id)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
data.Selected = make(map[int64]bool)
|
||||
for _, tag := range selectedTags {
|
||||
data.Selected[tag.ID] = true
|
||||
}
|
||||
|
||||
tmpl, err := template.ParseFiles("web/templates/rework-article.html")
|
||||
tmpl = template.Must(tmpl, err)
|
||||
tmpl.ExecuteTemplate(w, "page-content", article)
|
||||
tmpl.ExecuteTemplate(w, "page-content", data)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,16 @@
|
||||
{{define "page-content"}}
|
||||
<h2>Editor</h2>
|
||||
<form>
|
||||
<input name="article-title" placeholder="Titel" type="text" value="{{.Title}}" />
|
||||
<textarea name="article-description" placeholder="Beschreibung">{{.Description}}</textarea>
|
||||
<textarea name="article-content" placeholder="Artikel">{{.Content}}</textarea>
|
||||
<input name="article-id" type="hidden" value="{{.ID}}" />
|
||||
<input name="article-title" placeholder="Titel" type="text" value="{{.Article.Title}}" />
|
||||
<textarea name="article-description" placeholder="Beschreibung">{{.Article.Description}}</textarea>
|
||||
<textarea name="article-content" placeholder="Artikel">{{.Article.Content}}</textarea>
|
||||
<input name="article-id" type="hidden" value="{{.Article.ID}}" />
|
||||
|
||||
{{range .Tags}}
|
||||
<input id="tag-{{.Name}}" name="tags" type="checkbox" value="{{.ID}}" {{if index $.Selected .ID}}checked{{end}} />
|
||||
<label for="tag-{{.Name}}">{{.Name}}</label>
|
||||
{{end}}
|
||||
|
||||
<input type="submit" value="Senden" hx-post="/resubmit-article/" hx-target="#page-content" />
|
||||
</form>
|
||||
{{end}}
|
||||
|
@ -1,11 +1,19 @@
|
||||
{{define "page-content"}}
|
||||
<form>
|
||||
<h2>{{.Title}}</h2>
|
||||
<p>{{.Description}}</p>
|
||||
{{.Content}}
|
||||
<input name="id" type="hidden" value="{{.ID}}" />
|
||||
<h2>{{.Article.Title}}</h2>
|
||||
<p>{{.Article.Description}}</p>
|
||||
{{.Article.Content}}
|
||||
|
||||
<p>
|
||||
{{range .Tags}}
|
||||
{{.Name}}
|
||||
{{end}}
|
||||
</p>
|
||||
|
||||
<input name="id" type="hidden" value="{{.Article.ID}}" />
|
||||
<input type="submit" value="Veröffentlichen" hx-post="/publish-article/" hx-target="#page-content" />
|
||||
<input type="submit" value="Ablehnen" hx-post="/reject-article/" hx-target="#page-content" />
|
||||
</form>
|
||||
|
||||
<button hx-get="/hub/" hx-target="#page-content">Zurück</button>
|
||||
{{end}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user