🎨 Improve av

This commit is contained in:
Daniel 2025-08-11 23:52:11 +08:00
parent 62dbc08b9a
commit 7b3ac79d78
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -340,7 +340,7 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
}
}
}
case av.KeyTypeRollup: // 渲染汇总
case av.KeyTypeRollup: // 渲染汇总字段
rollupKey, _ := attrView.GetKey(value.KeyID)
if nil == rollupKey || nil == rollupKey.Rollup {
break
@ -402,12 +402,12 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
value.Rollup.RenderContents(rollupKey.Rollup.Calc, destKey)
// 将汇总列的值保存到 rowsValues 中,后续渲染模板列的时候会用到,下同
// 将汇总字段的值保存到 rowsValues 中,后续渲染模板字段的时候会用到,下同
// Database table view template columns support reading relation, rollup, created and updated columns https://github.com/siyuan-note/siyuan/issues/10442
keyValues := items[itemID]
keyValues = append(keyValues, &av.KeyValues{Key: rollupKey, Values: []*av.Value{{ID: value.ID, KeyID: rollupKey.ID, BlockID: itemID, Type: av.KeyTypeRollup, Rollup: value.Rollup}}})
items[itemID] = keyValues
case av.KeyTypeRelation: // 渲染关联
case av.KeyTypeRelation: // 渲染关联字段
relKey, _ := attrView.GetKey(value.KeyID)
if nil != relKey && nil != relKey.Relation {
destAv := avCache[relKey.Relation.AvID]
@ -480,6 +480,17 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
}
func fillAttributeViewTemplateValues(attrView *av.AttributeView, collection av.Collection, ials map[string]map[string]string, items map[string][]*av.KeyValues) (err error) {
existTemplateField := false
for _, kVals := range attrView.KeyValues {
if av.KeyTypeTemplate == kVals.Key.Type {
existTemplateField = true
break
}
}
if !existTemplateField {
return
}
var renderTemplateErr error
for _, item := range collection.GetItems() {
for _, value := range item.GetValues() {