From e8c4cd7aca31c8cb104a1ec6f0c9cf6cae5beb7a Mon Sep 17 00:00:00 2001 From: Will Bicks Date: Sun, 18 Dec 2022 22:36:28 -0500 Subject: [PATCH] Allow admins to view additional quote details (#11) * Allow admins to see who submitted a quote and when * Adjust error positioning --- internal/server/http/frontend/page.go | 6 +++ .../http/frontend/public/styles/app.css | 31 ++++++++---- .../templates/components/error.gohtml | 2 +- .../frontend/templates/views/quotes.gohtml | 35 +++++++++----- .../server/http/frontend/templating_test.go | 17 +++++++ internal/server/http/quotes_handler.go | 47 +++++++++++++++---- 6 files changed, 104 insertions(+), 34 deletions(-) diff --git a/internal/server/http/frontend/page.go b/internal/server/http/frontend/page.go index 7b7e19a..ffd9c18 100644 --- a/internal/server/http/frontend/page.go +++ b/internal/server/http/frontend/page.go @@ -28,9 +28,15 @@ func (PrivacyPage) viewName() string { // QuotesPage lists all quotes by year type QuotesPage struct { + // RenderAdmin is true if the page should render admin controls / info + RenderAdmin bool + Error error Quote model.Quote Quotes []model.Quote + + // Users is a map of user ID to user, and should only be populated if RenderAdmin is true + Users map[string]model.User } func (QuotesPage) viewName() string { diff --git a/internal/server/http/frontend/public/styles/app.css b/internal/server/http/frontend/public/styles/app.css index 9660134..20c9098 100644 --- a/internal/server/http/frontend/public/styles/app.css +++ b/internal/server/http/frontend/public/styles/app.css @@ -782,6 +782,10 @@ select { .link:hover { text-decoration-color: #60a5fa; } +.my-3 { + margin-top: 0.75rem; + margin-bottom: 0.75rem; +} .my-12 { margin-top: 3rem; margin-bottom: 3rem; @@ -812,6 +816,9 @@ select { .mb-4 { margin-bottom: 1rem; } +.mt-2 { + margin-top: 0.5rem; +} .block { display: block; } @@ -935,6 +942,10 @@ select { .lowercase { text-transform: lowercase; } +.text-gray-900 { + --tw-text-opacity: 1; + color: rgb(17 24 39 / var(--tw-text-opacity)); +} .text-red-700 { --tw-text-opacity: 1; color: rgb(185 28 28 / var(--tw-text-opacity)); @@ -951,9 +962,9 @@ select { --tw-text-opacity: 1; color: rgb(75 85 99 / var(--tw-text-opacity)); } -.text-gray-900 { +.text-gray-500 { --tw-text-opacity: 1; - color: rgb(17 24 39 / var(--tw-text-opacity)); + color: rgb(107 114 128 / var(--tw-text-opacity)); } .antialiased { -webkit-font-smoothing: antialiased; @@ -977,9 +988,9 @@ select { background-color: rgb(31 41 55 / var(--tw-bg-opacity)); } - .dark\:text-white { + .dark\:text-gray-100 { --tw-text-opacity: 1; - color: rgb(255 255 255 / var(--tw-text-opacity)); + color: rgb(243 244 246 / var(--tw-text-opacity)); } .dark\:text-gray-200 { @@ -987,19 +998,19 @@ select { color: rgb(229 231 235 / var(--tw-text-opacity)); } - .dark\:text-gray-400 { + .dark\:text-gray-300 { --tw-text-opacity: 1; - color: rgb(156 163 175 / var(--tw-text-opacity)); + color: rgb(209 213 219 / var(--tw-text-opacity)); } - .dark\:text-gray-100 { + .dark\:text-white { --tw-text-opacity: 1; - color: rgb(243 244 246 / var(--tw-text-opacity)); + color: rgb(255 255 255 / var(--tw-text-opacity)); } - .dark\:text-gray-300 { + .dark\:text-gray-500 { --tw-text-opacity: 1; - color: rgb(209 213 219 / var(--tw-text-opacity)); + color: rgb(107 114 128 / var(--tw-text-opacity)); } } diff --git a/internal/server/http/frontend/templates/components/error.gohtml b/internal/server/http/frontend/templates/components/error.gohtml index e1aa111..1a62a6c 100644 --- a/internal/server/http/frontend/templates/components/error.gohtml +++ b/internal/server/http/frontend/templates/components/error.gohtml @@ -1,6 +1,6 @@ {{define "error"}} {{with getIssues .}} -