🎨 The database rollup field supports using the template field https://github.com/siyuan-note/siyuan/issues/12384

This commit is contained in:
Daniel 2025-08-14 00:46:50 +08:00
parent b78616382b
commit 04351d74bc
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1470,8 +1470,21 @@ func GetBlockAttributeViewKeys(nodeID string) (ret []*BlockAttributeViewKeys) {
destKey, _ := destAv.GetKey(kv.Key.Rollup.KeyID)
if nil != destKey {
var furtherCollection av.Collection
if av.KeyTypeTemplate == destKey.Type {
// 渲染目标视图,这样才能汇总渲染后的模板字段值
viewable := sql.RenderView(destAv, destAv.Views[0], "")
if nil != viewable {
furtherCollection = viewable.(av.Collection)
}
}
for _, bID := range relVal.Relation.BlockIDs {
destVal := destAv.GetValue(kv.Key.Rollup.KeyID, bID)
if nil != furtherCollection && av.KeyTypeTemplate == destKey.Type {
destVal = furtherCollection.GetValue(bID, destKey.ID)
}
if nil == destVal {
if destAv.ExistItem(bID) { // 数据库中存在项目但是字段值不存在是数据未初始化,这里补一个默认值
destVal = av.GetAttributeViewDefaultValue(ast.NewNodeID(), kv.Key.Rollup.KeyID, bID, destKey.Type)