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 {
|
func ReviewUnpublishedArticle(db *model.DB, s *control.CookieStore) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
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)
|
id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
@ -162,21 +168,35 @@ func ReviewUnpublishedArticle(db *model.DB, s *control.CookieStore) http.Handler
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
article, err := db.GetArticle(id)
|
data.Article, err = db.GetArticle(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tmpl, err := template.ParseFiles("web/templates/to-be-published.html")
|
log.Println(err)
|
||||||
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", article)
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles("web/templates/to-be-published.html")
|
tmpl, err := template.ParseFiles("web/templates/to-be-published.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
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 {
|
func ReviewRejectedArticle(db *model.DB, s *control.CookieStore) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
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)
|
id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
@ -184,16 +204,34 @@ func ReviewRejectedArticle(db *model.DB, s *control.CookieStore) http.HandlerFun
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
article, err := db.GetArticle(id)
|
data.Article, err = db.GetArticle(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tmpl, err := template.ParseFiles("web/templates/to-be-published.html")
|
log.Println(err)
|
||||||
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", article)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
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, err := template.ParseFiles("web/templates/rework-article.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
tmpl.ExecuteTemplate(w, "page-content", article)
|
tmpl.ExecuteTemplate(w, "page-content", data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
{{define "page-content"}}
|
{{define "page-content"}}
|
||||||
<h2>Editor</h2>
|
<h2>Editor</h2>
|
||||||
<form>
|
<form>
|
||||||
<input name="article-title" placeholder="Titel" type="text" value="{{.Title}}" />
|
<input name="article-title" placeholder="Titel" type="text" value="{{.Article.Title}}" />
|
||||||
<textarea name="article-description" placeholder="Beschreibung">{{.Description}}</textarea>
|
<textarea name="article-description" placeholder="Beschreibung">{{.Article.Description}}</textarea>
|
||||||
<textarea name="article-content" placeholder="Artikel">{{.Content}}</textarea>
|
<textarea name="article-content" placeholder="Artikel">{{.Article.Content}}</textarea>
|
||||||
<input name="article-id" type="hidden" value="{{.ID}}" />
|
<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" />
|
<input type="submit" value="Senden" hx-post="/resubmit-article/" hx-target="#page-content" />
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
{{define "page-content"}}
|
{{define "page-content"}}
|
||||||
<form>
|
<form>
|
||||||
<h2>{{.Title}}</h2>
|
<h2>{{.Article.Title}}</h2>
|
||||||
<p>{{.Description}}</p>
|
<p>{{.Article.Description}}</p>
|
||||||
{{.Content}}
|
{{.Article.Content}}
|
||||||
<input name="id" type="hidden" value="{{.ID}}" />
|
|
||||||
|
<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="Veröffentlichen" hx-post="/publish-article/" hx-target="#page-content" />
|
||||||
<input type="submit" value="Ablehnen" hx-post="/reject-article/" hx-target="#page-content" />
|
<input type="submit" value="Ablehnen" hx-post="/reject-article/" hx-target="#page-content" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<button hx-get="/hub/" hx-target="#page-content">Zurück</button>
|
<button hx-get="/hub/" hx-target="#page-content">Zurück</button>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user