Clean up.

This commit is contained in:
mikestefanello 2025-04-13 09:32:43 -04:00
parent 60afbb18c0
commit 8c3f04e859
5 changed files with 26 additions and 27 deletions

View file

@ -26,7 +26,7 @@ func (*Extension) Templates() []*gen.Template {
gen.NewTemplate("admin").
Funcs(template.FuncMap{
"fieldName": fieldName,
"fieldLabel": fieldLabel,
"fieldLabel": FieldLabel,
"fieldIsPointer": fieldIsPointer,
}).
ParseFS(templateDir, "templates/*tmpl"),
@ -51,13 +51,14 @@ func fieldName(name string) string {
return strings.Join(parts, "")
}
func fieldLabel(name string) string {
func FieldLabel(name string) string {
if len(name) == 0 {
return name
}
out := strings.ReplaceAll(name, "_", " ")
return upperFirst(out)
name = strings.ReplaceAll(name, "_id", "_ID")
name = strings.ReplaceAll(name, "_", " ")
return upperFirst(name)
}
func fieldIsPointer(f *gen.Field) bool {

View file

@ -138,7 +138,7 @@ func (h *Handler) PasswordTokenList(ctx echo.Context) (*EntityList, error) {
list := &EntityList{
Columns: []string{
"User id",
"User ID",
"Created at",
},
Entities: make([]EntityValues, 0, len(res)),

View file

@ -20,6 +20,7 @@ type PasswordToken struct {
// Fields of the PasswordToken.
func (PasswordToken) Fields() []ent.Field {
return []ent.Field{
// TODO rename to Token
field.String("hash").
Sensitive().
NotEmpty(),