Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-10-06 10:26:14 +08:00
commit 3058b10cfe
2 changed files with 11 additions and 5 deletions

View file

@ -82,11 +82,12 @@ type Key struct {
Template string `json:"template"` // 模板内容
}
func NewKey(id, name string, keyType KeyType) *Key {
func NewKey(id, name, icon string, keyType KeyType) *Key {
return &Key{
ID: id,
Name: name,
Type: keyType,
Icon: icon,
}
}
@ -397,7 +398,7 @@ type Viewable interface {
func NewAttributeView(id string) (ret *AttributeView) {
view := NewView()
key := NewKey(ast.NewNodeID(), "Block", KeyTypeBlock)
key := NewKey(ast.NewNodeID(), "Block", "", KeyTypeBlock)
ret = &AttributeView{
Spec: 0,
ID: id,

View file

@ -50,13 +50,18 @@ func renderTemplateCol(blockID, tplContent string, rowValues []*av.KeyValues) st
buf := &bytes.Buffer{}
ial := GetBlockAttrs(blockID)
dataModel := map[string]string{} // 复制一份 IAL 以避免修改原始数据
dataModel := map[string]interface{}{} // 复制一份 IAL 以避免修改原始数据
for k, v := range ial {
dataModel[strings.ReplaceAll(k, "custom-", "custom_")] = v
}
for _, rowValue := range rowValues {
if 0 < len(rowValue.Values) {
dataModel[rowValue.Key.Name] = rowValue.Values[0].String()
v := rowValue.Values[0]
if av.KeyTypeNumber == v.Type {
dataModel[rowValue.Key.Name] = v.Number.Content
} else {
dataModel[rowValue.Key.Name] = v.String()
}
}
}
if err := tpl.Execute(buf, dataModel); nil != err {
@ -898,7 +903,7 @@ func addAttributeViewColumn(operation *Operation) (err error) {
keyType := av.KeyType(operation.Typ)
switch keyType {
case av.KeyTypeText, av.KeyTypeNumber, av.KeyTypeDate, av.KeyTypeSelect, av.KeyTypeMSelect, av.KeyTypeURL, av.KeyTypeEmail, av.KeyTypePhone, av.KeyTypeMAsset, av.KeyTypeTemplate:
key := av.NewKey(operation.ID, operation.Name, keyType)
key := av.NewKey(operation.ID, operation.Name, operation.Data.(string), keyType)
attrView.KeyValues = append(attrView.KeyValues, &av.KeyValues{Key: key})
switch view.LayoutType {