mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
🎨 Improve av https://github.com/siyuan-note/siyuan/issues/14511
This commit is contained in:
parent
0220f38d94
commit
548ae028cc
5 changed files with 16 additions and 16 deletions
|
|
@ -564,9 +564,9 @@ func (av *AttributeView) GetCurrentView(viewID string) (ret *View, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (av *AttributeView) ExistBlock(blockID string) bool {
|
func (av *AttributeView) ExistItem(itemID string) bool {
|
||||||
for _, blockVal := range av.GetBlockKeyValues().Values {
|
for _, blockVal := range av.GetBlockKeyValues().Values {
|
||||||
if blockVal.BlockID == blockID {
|
if blockVal.BlockID == itemID {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -582,11 +582,11 @@ func (av *AttributeView) ExistBoundBlock(nodeID string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (av *AttributeView) GetValue(keyID, blockID string) (ret *Value) {
|
func (av *AttributeView) GetValue(keyID, itemID string) (ret *Value) {
|
||||||
for _, kv := range av.KeyValues {
|
for _, kv := range av.KeyValues {
|
||||||
if kv.Key.ID == keyID {
|
if kv.Key.ID == keyID {
|
||||||
for _, v := range kv.Values {
|
for _, v := range kv.Values {
|
||||||
if v.BlockID == blockID {
|
if v.BlockID == itemID {
|
||||||
ret = v
|
ret = v
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, rowID st
|
||||||
for _, blockID := range relVal.Relation.BlockIDs {
|
for _, blockID := range relVal.Relation.BlockIDs {
|
||||||
destVal := destAv.GetValue(key.Rollup.KeyID, blockID)
|
destVal := destAv.GetValue(key.Rollup.KeyID, blockID)
|
||||||
if nil == destVal {
|
if nil == destVal {
|
||||||
if destAv.ExistBlock(blockID) { // 数据库中存在项目但是字段值不存在是数据未初始化,这里补一个默认值
|
if destAv.ExistItem(blockID) { // 数据库中存在项目但是字段值不存在是数据未初始化,这里补一个默认值
|
||||||
destVal = GetAttributeViewDefaultValue(ast.NewNodeID(), key.Rollup.KeyID, blockID, destKey.Type)
|
destVal = GetAttributeViewDefaultValue(ast.NewNodeID(), key.Rollup.KeyID, blockID, destKey.Type)
|
||||||
}
|
}
|
||||||
if nil == destVal {
|
if nil == destVal {
|
||||||
|
|
|
||||||
|
|
@ -1378,7 +1378,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
|
||||||
for _, bID := range relVal.Relation.BlockIDs {
|
for _, bID := range relVal.Relation.BlockIDs {
|
||||||
destVal := destAv.GetValue(kv.Key.Rollup.KeyID, bID)
|
destVal := destAv.GetValue(kv.Key.Rollup.KeyID, bID)
|
||||||
if nil == destVal {
|
if nil == destVal {
|
||||||
if destAv.ExistBlock(bID) { // 数据库中存在项目但是字段值不存在是数据未初始化,这里补一个默认值
|
if destAv.ExistItem(bID) { // 数据库中存在项目但是字段值不存在是数据未初始化,这里补一个默认值
|
||||||
destVal = av.GetAttributeViewDefaultValue(ast.NewNodeID(), kv.Key.Rollup.KeyID, bID, destKey.Type)
|
destVal = av.GetAttributeViewDefaultValue(ast.NewNodeID(), kv.Key.Rollup.KeyID, bID, destKey.Type)
|
||||||
}
|
}
|
||||||
if nil == destVal {
|
if nil == destVal {
|
||||||
|
|
@ -2542,20 +2542,20 @@ func (tx *Transaction) getAttrViewBoundNodes(attrView *av.AttributeView) (trees
|
||||||
}
|
}
|
||||||
|
|
||||||
var tree *parse.Tree
|
var tree *parse.Tree
|
||||||
tree = trees[blockKeyValue.BlockID]
|
tree = trees[blockKeyValue.Block.ID]
|
||||||
if nil == tree {
|
if nil == tree {
|
||||||
if nil == tx {
|
if nil == tx {
|
||||||
tree, _ = LoadTreeByBlockID(blockKeyValue.BlockID)
|
tree, _ = LoadTreeByBlockID(blockKeyValue.Block.ID)
|
||||||
} else {
|
} else {
|
||||||
tree, _ = tx.loadTree(blockKeyValue.BlockID)
|
tree, _ = tx.loadTree(blockKeyValue.Block.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if nil == tree {
|
if nil == tree {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
trees[blockKeyValue.BlockID] = tree
|
trees[blockKeyValue.Block.ID] = tree
|
||||||
|
|
||||||
node := treenode.GetNodeInTree(tree, blockKeyValue.BlockID)
|
node := treenode.GetNodeInTree(tree, blockKeyValue.Block.ID)
|
||||||
if nil == node {
|
if nil == node {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,7 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil == destVal {
|
if nil == destVal {
|
||||||
if destAv.ExistBlock(blockID) { // 数据库中存在项目但是字段值不存在是数据未初始化,这里补一个默认值
|
if destAv.ExistItem(blockID) { // 数据库中存在项目但是字段值不存在是数据未初始化,这里补一个默认值
|
||||||
destVal = av.GetAttributeViewDefaultValue(ast.NewNodeID(), rollupKey.Rollup.KeyID, blockID, destKey.Type)
|
destVal = av.GetAttributeViewDefaultValue(ast.NewNodeID(), rollupKey.Rollup.KeyID, blockID, destKey.Type)
|
||||||
}
|
}
|
||||||
if nil == destVal {
|
if nil == destVal {
|
||||||
|
|
|
||||||
|
|
@ -136,11 +136,11 @@ func fillAttributeViewGalleryCardCover(attrView *av.AttributeView, view *av.View
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
tree := trees[blockValue.BlockID]
|
tree := trees[blockValue.Block.ID]
|
||||||
if nil == tree {
|
if nil == tree {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
node := treenode.GetNodeInTree(tree, blockValue.BlockID)
|
node := treenode.GetNodeInTree(tree, blockValue.Block.ID)
|
||||||
if nil == node {
|
if nil == node {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -199,11 +199,11 @@ func fillAttributeViewGalleryCardCover(attrView *av.AttributeView, view *av.View
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
tree := trees[blockValue.BlockID]
|
tree := trees[blockValue.Block.ID]
|
||||||
if nil == tree {
|
if nil == tree {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
node := treenode.GetNodeInTree(tree, blockValue.BlockID)
|
node := treenode.GetNodeInTree(tree, blockValue.Block.ID)
|
||||||
if nil == node {
|
if nil == node {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue