Added button to add companies
This commit is contained in:
parent
c5cb497722
commit
54b08453dc
@ -1,8 +1,6 @@
|
||||
package companies
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
@ -19,10 +17,6 @@ func Get(ctx *aero.Context) string {
|
||||
return !company.IsDraft
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Error fetching companies", err)
|
||||
}
|
||||
|
||||
if len(companies) > maxEntries {
|
||||
companies = companies[:maxEntries]
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
component Companies(companies []*arn.Company, user *arn.User)
|
||||
h1.page-title Companies
|
||||
|
||||
.music-buttons
|
||||
if user != nil
|
||||
if user.DraftIndex().CompanyID == ""
|
||||
button.action(data-action="newObject", data-trigger="click", data-type="company")
|
||||
Icon("plus")
|
||||
span Add company
|
||||
else
|
||||
a.button.ajax(href="/company/" + user.DraftIndex().CompanyID + "/edit")
|
||||
Icon("pencil")
|
||||
span Edit draft
|
||||
|
||||
ul
|
||||
each company in companies
|
||||
li= company.Name.English
|
@ -6,10 +6,12 @@ import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Get company.
|
||||
func Get(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
company, err := arn.GetCompany(id)
|
||||
|
||||
@ -17,5 +19,5 @@ func Get(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusNotFound, "Company not found", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.CompanyPage(company))
|
||||
return ctx.HTML(components.CompanyPage(company, user))
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
component CompanyPage(company *arn.Company)
|
||||
component CompanyPage(company *arn.Company, user *arn.User)
|
||||
h1= company.Name.English
|
@ -13,6 +13,7 @@ import (
|
||||
"github.com/animenotifier/notify.moe/pages/apiview"
|
||||
"github.com/animenotifier/notify.moe/pages/character"
|
||||
"github.com/animenotifier/notify.moe/pages/charge"
|
||||
"github.com/animenotifier/notify.moe/pages/companies"
|
||||
"github.com/animenotifier/notify.moe/pages/company"
|
||||
"github.com/animenotifier/notify.moe/pages/compare"
|
||||
"github.com/animenotifier/notify.moe/pages/database"
|
||||
@ -95,6 +96,7 @@ func Configure(app *aero.Application) {
|
||||
|
||||
// Companies
|
||||
l.Page("/company/:id", company.Get)
|
||||
l.Page("/companies", companies.Get)
|
||||
|
||||
// Settings
|
||||
l.Page("/settings", settings.Get(components.SettingsPersonal))
|
||||
|
Loading…
Reference in New Issue
Block a user