Company UI improvements

This commit is contained in:
Eduard Urbach 2017-11-19 02:04:37 +01:00
parent 604a41c503
commit d540ea1ffb
4 changed files with 21 additions and 2 deletions

View File

@ -1,6 +1,8 @@
package companies
import (
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
@ -17,6 +19,10 @@ func Get(ctx *aero.Context) string {
return !company.IsDraft
})
sort.Slice(companies, func(i, j int) bool {
return companies[i].Created > companies[j].Created
})
if len(companies) > maxEntries {
companies = companies[:maxEntries]
}

View File

@ -14,4 +14,5 @@ component Companies(companies []*arn.Company, user *arn.User)
ul
each company in companies
li= company.Name.English
li
a.ajax(href=company.Link())= company.Name.English

View File

@ -0,0 +1,3 @@
.company-description
max-width 700px
margin 0 auto

View File

@ -33,7 +33,16 @@ func Render(obj interface{}, title string, user *arn.User) string {
if user != nil {
b.WriteString(`<div class="buttons">`)
b.WriteString(`<div class="buttons"><button class="action" data-action="publish" data-trigger="click">` + utils.Icon("share-alt") + `Publish</button></div>`)
_, ok := t.FieldByName("IsDraft")
if ok {
isDraft := v.FieldByName("IsDraft").Interface().(bool)
if isDraft {
b.WriteString(`<div class="buttons"><button class="action" data-action="publish" data-trigger="click">` + utils.Icon("share-alt") + `Publish</button></div>`)
}
}
if user.Role == "editor" || user.Role == "admin" {
b.WriteString(`<button class="action" data-action="deleteObject" data-trigger="click" data-return-path="/` + lowerCaseTypeName + "s" + `" data-confirm-type="` + lowerCaseTypeName + `">` + utils.Icon("trash") + `Delete</button>`)