package component
import (
"path/filepath"
"strings"
"management/internal/erpserver/model/dto"
"github.com/a-h/templ"
)
func TemplBtn(buttons []dto.OwnerMenuDto, searchBtn bool, actionNames ...string) templ.Component {
var b strings.Builder
b.WriteString(``)
return templ.Raw(b.String())
}
func TemplLink(buttons []dto.OwnerMenuDto, actionNames ...string) templ.Component {
var b strings.Builder
b.WriteString(``)
return templ.Raw(b.String())
}
func GenBtn(buttons []dto.OwnerMenuDto, actionNames ...string) string {
if len(buttons) == 0 {
return ""
}
if len(actionNames) == 0 {
return ""
}
var b strings.Builder
for _, action := range actionNames {
for _, btn := range buttons {
btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui")
base := filepath.Base(btn.Url)
if base == action {
b.WriteString(``)
}
}
}
return b.String()
}
func GenLink(buttons []dto.OwnerMenuDto, actionNames ...string) string {
if len(buttons) == 0 {
return ""
}
if len(actionNames) == 0 {
return ""
}
var b strings.Builder
for _, action := range actionNames {
for _, btn := range buttons {
btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui")
base := filepath.Base(btn.Url)
if base == action {
b.WriteString(``)
}
}
}
return b.String()
}
func SubmitBtn(buttons []dto.OwnerMenuDto, actionNames ...string) templ.Component {
if len(buttons) == 0 {
return templ.Raw("")
}
if len(actionNames) == 0 {
return templ.Raw("")
}
var b strings.Builder
for _, action := range actionNames {
for _, btn := range buttons {
btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui")
base := filepath.Base(btn.Url)
if base == action {
b.WriteString(``)
}
}
}
return templ.Raw(b.String())
}
func firstLower(s string) string {
if len(s) == 0 {
return s
}
return strings.ToLower(s[:1]) + s[1:]
}