From 9a57a56886ad8309790a01d443163ad6d4371689 Mon Sep 17 00:00:00 2001 From: Lucas Brown Date: Mon, 5 Aug 2019 19:21:24 -0800 Subject: [PATCH] Enhancements to users when status is invited. --- cmd/web-app/handlers/users.go | 14 ++++-- .../templates/content/users-invite.gohtml | 46 +++++++++---------- .../templates/content/users-view.gohtml | 11 ++++- internal/user_account/models.go | 5 +- 4 files changed, 44 insertions(+), 32 deletions(-) diff --git a/cmd/web-app/handlers/users.go b/cmd/web-app/handlers/users.go index ec29bf6..e0b9526 100644 --- a/cmd/web-app/handlers/users.go +++ b/cmd/web-app/handlers/users.go @@ -102,7 +102,11 @@ func (h *Users) Index(ctx context.Context, w http.ResponseWriter, r *http.Reques case "id": v.Value = fmt.Sprintf("%d", q.ID) case "name": - v.Value = q.Name + if strings.TrimSpace(q.Name) == "" { + v.Value = q.Email + } else { + v.Value = q.Name + } v.Formatted = fmt.Sprintf("%s", urlUsersView(q.ID), v.Value) case "status": v.Value = q.Status.String() @@ -112,13 +116,13 @@ func (h *Users) Index(ctx context.Context, w http.ResponseWriter, r *http.Reques switch q.Status { case user_account.UserAccountStatus_Active: subStatusClass = "text-green" - subStatusIcon = "far fa-dot-circle" + subStatusIcon = "fas fa-circle" case user_account.UserAccountStatus_Invited: - subStatusClass = "text-blue" - subStatusIcon = "far fa-unicorn" + subStatusClass = "text-aqua" + subStatusIcon = "far fa-dot-circle" case user_account.UserAccountStatus_Disabled: subStatusClass = "text-orange" - subStatusIcon = "far fa-circle" + subStatusIcon = "fas fa-circle-notch" } v.Formatted = fmt.Sprintf("%s", subStatusClass, subStatusIcon, web.EnumValueTitle(v.Value)) diff --git a/cmd/web-app/templates/content/users-invite.gohtml b/cmd/web-app/templates/content/users-invite.gohtml index 57fbcf5..b0120fe 100644 --- a/cmd/web-app/templates/content/users-invite.gohtml +++ b/cmd/web-app/templates/content/users-invite.gohtml @@ -15,22 +15,11 @@
-
-
+
+ +
-
- - - {{template "invalid-feedback" dict "validationDefaults" $.validationDefaults "validationErrors" $.validationErrors "fieldName" "Roles" }} -
- -
@@ -41,23 +30,34 @@

Add another invitation

-
-
+
+
- - + + + + {{ range $t := .roles.Options }} +
+ + + +
+ {{ end }} {{template "invalid-feedback" dict "validationDefaults" $.validationDefaults "validationErrors" $.validationErrors "fieldName" "Roles" }}
+ +
+
diff --git a/cmd/web-app/templates/content/users-view.gohtml b/cmd/web-app/templates/content/users-view.gohtml index 97ff862..c4d6181 100644 --- a/cmd/web-app/templates/content/users-view.gohtml +++ b/cmd/web-app/templates/content/users-view.gohtml @@ -7,13 +7,16 @@
-

{{ .user.Name }}

+ +

+ {{ if eq .userAccount.Status.Value "invited" }}{{ .user.Email }}{{else}}{{ .user.Name }}{{end}} +

{{ if HasRole $._Ctx "admin" }} {{ end }} @@ -58,7 +61,11 @@

Name
+ {{if .user.FirstName }} {{ .user.Name }} + {{else}} + Not Set + {{end}}

Email
diff --git a/internal/user_account/models.go b/internal/user_account/models.go index 9fe5bfa..2b63ef0 100644 --- a/internal/user_account/models.go +++ b/internal/user_account/models.go @@ -3,10 +3,11 @@ package user_account import ( "context" "database/sql/driver" - "geeks-accelerator/oss/saas-starter-kit/internal/platform/web" + "strings" "time" "geeks-accelerator/oss/saas-starter-kit/internal/platform/auth" + "geeks-accelerator/oss/saas-starter-kit/internal/platform/web" "github.com/lib/pq" "github.com/pkg/errors" "gopkg.in/go-playground/validator.v9" @@ -341,7 +342,7 @@ func (m *User) Response(ctx context.Context) *UserResponse { r.Timezone = *m.Timezone } - if r.Name == "" { + if strings.TrimSpace(r.Name) == "" { r.Name = r.Email }