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

This commit is contained in:
Daniel 2024-01-01 16:08:46 +08:00
parent 6ae523bcd6
commit d9a0d89668
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 21 additions and 17 deletions

View file

@ -245,18 +245,18 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
destAv, _ := av.ParseAttributeView(relKey.Relation.AvID)
if nil != destAv {
for _, bID := range relVal.Relation.BlockIDs {
destKey, _ := destAv.GetKey(kv.Key.Rollup.KeyID)
if nil == destKey {
continue
}
destVal := destAv.GetValue(kv.Key.Rollup.KeyID, bID)
if nil == destVal {
destKey, _ := destAv.GetKey(kv.Key.Rollup.KeyID)
if nil == destKey {
continue
}
destVal = treenode.GetAttributeViewDefaultValue(ast.NewNodeID(), kv.Key.Rollup.KeyID, blockID, destKey.Type)
}
if av.KeyTypeNumber == destVal.Type {
destVal.Number.Format = kv.Key.NumberFormat
if av.KeyTypeNumber == destKey.Type {
destVal.Number.Format = destKey.NumberFormat
destVal.Number.FormatNumber()
}
@ -818,17 +818,17 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
}
for _, blockID := range relVal.Relation.BlockIDs {
destKey, _ := destAv.GetKey(rollupKey.Rollup.KeyID)
if nil == destKey {
continue
}
destVal := destAv.GetValue(rollupKey.Rollup.KeyID, blockID)
if nil == destVal {
destKey, _ := destAv.GetKey(rollupKey.Rollup.KeyID)
if nil == destKey {
continue
}
destVal = treenode.GetAttributeViewDefaultValue(ast.NewNodeID(), rollupKey.Rollup.KeyID, blockID, destKey.Type)
}
if av.KeyTypeNumber == destVal.Type {
destVal.Number.Format = rollupKey.NumberFormat
if av.KeyTypeNumber == destKey.Type {
destVal.Number.Format = destKey.NumberFormat
destVal.Number.FormatNumber()
}

View file

@ -775,17 +775,21 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
}
for _, blockID := range relVal.Relation.BlockIDs {
destKey, _ := destAv.GetKey(rollupKey.Rollup.KeyID)
if nil == destKey {
continue
}
destVal := destAv.GetValue(rollupKey.Rollup.KeyID, blockID)
if nil == destVal {
destKey, _ := destAv.GetKey(rollupKey.Rollup.KeyID)
if nil == destKey {
continue
}
destVal = GetAttributeViewDefaultValue(ast.NewNodeID(), rollupKey.Rollup.KeyID, blockID, destKey.Type)
}
if av.KeyTypeNumber == destVal.Type {
destVal.Number.Format = rollupKey.NumberFormat
if av.KeyTypeNumber == destKey.Type {
destVal.Number.Format = destKey.NumberFormat
destVal.Number.FormatNumber()
}