🎨 Add Rollup column to database table view https://github.com/siyuan-note/siyuan/issues/9958

This commit is contained in:
Daniel 2023-12-24 22:27:38 +08:00
parent 93dc9f5c22
commit 0ce8b58a79
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 110 additions and 13 deletions

View file

@ -723,6 +723,30 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
}
content := renderTemplateCol(ial, cell.Value.Template.Content, keyValues)
cell.Value.Template.Content = content
case av.KeyTypeRollup: // 渲染汇总列
rollupKey, _ := attrView.GetKey(cell.Value.KeyID)
if nil == rollupKey || nil == rollupKey.Rollup {
break
}
relKey, _ := attrView.GetKey(rollupKey.Rollup.RelationKeyID)
if nil == relKey || nil == relKey.Relation {
break
}
relVal := attrView.GetValue(relKey.ID, row.ID)
if nil == relVal || nil == relVal.Relation {
break
}
destAv, _ := av.ParseAttributeView(relKey.Relation.AvID)
if nil == destAv {
break
}
for _, blockID := range relVal.Relation.BlockIDs {
cell.Value.Rollup.Contents = append(cell.Value.Rollup.Contents, destAv.GetValue(rollupKey.Rollup.KeyID, blockID).String())
}
case av.KeyTypeRelation: // 渲染关联列
relKey, _ := attrView.GetKey(cell.Value.KeyID)
if nil != relKey && nil != relKey.Relation {