From 08b7a0e75c90aea6be54351a2798c76ca0cbbe33 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 1 Mar 2018 22:44:14 +0100 Subject: [PATCH] Improved companies view --- layout/sidebar/sidebar.pixy | 1 + pages/companies/companies.go | 5 +++++ pages/companies/companies.pixy | 10 +++++----- pages/companies/companies.scarlet | 8 ++++---- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/layout/sidebar/sidebar.pixy b/layout/sidebar/sidebar.pixy index 0c842e73..bb7334b2 100644 --- a/layout/sidebar/sidebar.pixy +++ b/layout/sidebar/sidebar.pixy @@ -27,6 +27,7 @@ component Sidebar(user *arn.User) SidebarButton("Calendar", "/calendar", "calendar") SidebarButton("Soundtracks", "/soundtracks", "headphones") SidebarButton("Quotes", "/quotes", "quote-left") + SidebarButton("Companies", "/companies", "building") SidebarButton("Users", "/users", "globe") if user != nil diff --git a/pages/companies/companies.go b/pages/companies/companies.go index 5b379e22..a5105703 100644 --- a/pages/companies/companies.go +++ b/pages/companies/companies.go @@ -3,6 +3,7 @@ package companies import ( "sort" "strings" + "unicode" "github.com/aerogo/aero" "github.com/animenotifier/arn" @@ -30,6 +31,10 @@ func All(ctx *aero.Context) string { for _, company := range companies { firstLetter := strings.ToLower(company.Name.English[:1]) + if !unicode.IsLetter([]rune(firstLetter)[0]) { + continue + } + if firstLetter != previousFirstLetter { groups = append(groups, []*arn.Company{}) currentGroupIndex++ diff --git a/pages/companies/companies.pixy b/pages/companies/companies.pixy index 1fdecdfb..c8986204 100644 --- a/pages/companies/companies.pixy +++ b/pages/companies/companies.pixy @@ -3,14 +3,14 @@ component Companies(groups [][]*arn.Company, user *arn.User) h1.page-title All companies - .companies + .company-groups each group in groups - .companies-group - h3= group[0].Name.English[:1] + .company-group.mountable + h3= strings.ToUpper(group[0].Name.English[:1]) ul each company in group - li.mountable + li a.ajax(href=company.Link())= company.Name.English component CompaniesTabs(user *arn.User) @@ -19,7 +19,7 @@ component CompaniesTabs(user *arn.User) Tab("Popular", "globe", "/companies/popular") .corner-buttons - if user != nil + if user != nil && (user.Role == "editor" || user.Role == "admin") if user.DraftIndex().CompanyID == "" button.action(data-action="newObject", data-trigger="click", data-type="company") Icon("plus") diff --git a/pages/companies/companies.scarlet b/pages/companies/companies.scarlet index 6291f0ef..a5fee370 100644 --- a/pages/companies/companies.scarlet +++ b/pages/companies/companies.scarlet @@ -1,5 +1,5 @@ -.companies - // +.company-groups + horizontal-wrap -.companies-group - // \ No newline at end of file +.company-group + padding 1rem \ No newline at end of file