Commit 9a57a568 authored by Lucas Brown's avatar Lucas Brown

Enhancements to users when status is invited.

parent 74c0223f
......@@ -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("<a href='%s'>%s</a>", 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("<span class='cell-font-status %s'><i class='%s mr-1'></i>%s</span>", subStatusClass, subStatusIcon, web.EnumValueTitle(v.Value))
......
......@@ -15,21 +15,10 @@
<form method="POST">
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-body">
<div class="form-group">
<label for="selectRoles">Roles <small>- Select at least one role for invited user(s).</small></label>
<select class="form-control {{ ValidationFieldClass $.validationErrors "Roles" }}"
id="selectRoles" name="Roles" multiple="multiple">
{{ range $t := .roles }}
<option value="{{ $t.Value }}" {{ if $t.Selected }}selected="selected"{{ end }}>{{ $t.Title }}</option>
{{ end }}
</select>
{{template "invalid-feedback" dict "validationDefaults" $.validationDefaults "validationErrors" $.validationErrors "fieldName" "Roles" }}
</div>
<div class="col">
<div class="card mb-4">
<div class="card-body">
<div id="email-form-groups">
<div class="form-group">
......@@ -41,23 +30,34 @@
<p class="mt-2 mb-0"><a href="javascript:void(0)" class="btn btn-outline-primary btn-sm" id="inviteUser1"><i class="fas fa-user-plus mr-1"></i>Add another invitation</a></p>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-body">
<div class="form-group">
<label for="selectRoles">Roles</label>
<select class="form-control {{ ValidationFieldClass $.validationErrors "Roles" }}"
id="selectRoles" name="Roles" multiple="multiple">
{{ range $t := .roles.Options }}
<option value="{{ $t.Value }}" {{ if $t.Selected }}selected="selected"{{ end }}>{{ $t.Title }}</option>
{{ end }}
</select>
<label for="selectRoles">Roles <small>- Select at least one role for invited user(s).</small></label>
{{ range $t := .roles.Options }}
<div class="form-check">
<input class="form-check-input {{ ValidationFieldClass $.validationErrors "Roles" }}"
type="checkbox" name="Roles"
value="{{ $t.Value }}" id="inputRole{{ $t.Value }}"
{{ if $t.Selected }}checked="checked"{{ end }}>
<label class="form-check-label" for="inputRole{{ $t.Value }}">
{{ $t.Title }}
</label>
</div>
{{ end }}
{{template "invalid-feedback" dict "validationDefaults" $.validationDefaults "validationErrors" $.validationErrors "fieldName" "Roles" }}
</div>
</div>
</div>
</div>
</div>
......
......@@ -7,13 +7,16 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/users">Users</a></li>
<li class="breadcrumb-item"><a href="{{ .urlUsersView }}">{{ .user.Name }}</a></li>
<li class="breadcrumb-item"><a href="{{ .urlUsersView }}">{{ if eq .userAccount.Status.Value "invited" }}{{ .user.Email }}{{else}}{{ .user.Name }}{{end}}</a></li>
<li class="breadcrumb-item active" aria-current="page">View</li>
</ol>
</nav>
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">{{ .user.Name }}</h1>
<h1 class="h3 mb-0 text-gray-800">
{{ if eq .userAccount.Status.Value "invited" }}{{ .user.Email }}{{else}}{{ .user.Name }}{{end}}
</h1>
{{ if HasRole $._Ctx "admin" }}
<!-- a href="/user/update" class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i class="far fa-edit fa-sm text-white-50 mr-1"></i>Edit Details</a -->
{{ end }}
......@@ -58,7 +61,11 @@
<div class="col-md-5">
<p>
<small>Name</small><br/>
{{if .user.FirstName }}
<b>{{ .user.Name }}</b>
{{else}}
<em>Not Set</em>
{{end}}
</p>
<p>
<small>Email</small><br/>
......
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment