package tpl
import (
	"html/template"
	"path/filepath"
	"strings"
	"management/internal/erpserver/model/dto"
)
func (r *render) btnFuncs() map[string]any {
	res := make(map[string]any, 3)
	res["genBtn"] = func(btns []*dto.OwnerMenuDto, actionNames ...string) template.HTML {
		if len(btns) == 0 {
			return template.HTML("")
		}
		var res string
		for _, action := range actionNames {
			for _, btn := range btns {
				btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui")
				base := filepath.Base(btn.Url)
				if base == action {
					res += ``
				}
			}
		}
		return template.HTML(res)
	}
	res["genLink"] = func(btns []*dto.OwnerMenuDto, actionNames ...string) template.HTML {
		if len(btns) == 0 {
			return template.HTML("")
		}
		var res string
		for _, action := range actionNames {
			for _, btn := range btns {
				btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui")
				base := filepath.Base(btn.Url)
				if base == action {
					res += ``
				}
			}
		}
		return template.HTML(res)
	}
	res["previewPicture"] = func(name string) template.HTML {
		var res string
		res += ` `
		return template.HTML(res)
	}
	res["submitBtn"] = func(btns []*dto.OwnerMenuDto, actionNames ...string) template.HTML {
		if len(btns) == 0 {
			return template.HTML("")
		}
		var res string
		for _, action := range actionNames {
			for _, btn := range btns {
				btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui")
				base := filepath.Base(btn.Url)
				if base == action {
					res += ``
				}
			}
		}
		return template.HTML(res)
	}
	return res
}
`
		return template.HTML(res)
	}
	res["submitBtn"] = func(btns []*dto.OwnerMenuDto, actionNames ...string) template.HTML {
		if len(btns) == 0 {
			return template.HTML("")
		}
		var res string
		for _, action := range actionNames {
			for _, btn := range btns {
				btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui")
				base := filepath.Base(btn.Url)
				if base == action {
					res += ``
				}
			}
		}
		return template.HTML(res)
	}
	return res
}