mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-28 01:44:07 +01:00
🎨 Rows non-bound in the database support Add to Database https://github.com/siyuan-note/siyuan/issues/11093
This commit is contained in:
parent
4cc2d9a6a8
commit
0f06692da4
3 changed files with 33 additions and 27 deletions
|
|
@ -2165,37 +2165,39 @@ func setAttributeViewColumnCalc(operation *Operation) (err error) {
|
|||
}
|
||||
|
||||
func (tx *Transaction) doInsertAttrViewBlock(operation *Operation) (ret *TxErr) {
|
||||
err := AddAttributeViewBlock(tx, operation.SrcIDs, operation.AvID, operation.BlockID, operation.PreviousID, operation.Name, operation.IsDetached, operation.IgnoreFillFilterVal)
|
||||
err := AddAttributeViewBlock(tx, operation.Srcs, operation.AvID, operation.BlockID, operation.PreviousID, operation.IsDetached, operation.IgnoreFillFilterVal)
|
||||
if nil != err {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func AddAttributeViewBlock(tx *Transaction, srcIDs []string, avID, blockID, previousBlockID, content string, isDetached, ignoreFillFilter bool) (err error) {
|
||||
for _, id := range srcIDs {
|
||||
func AddAttributeViewBlock(tx *Transaction, srcs []map[string]interface{}, avID, blockID, previousBlockID string, isDetached, ignoreFillFilter bool) (err error) {
|
||||
for _, src := range srcs {
|
||||
srcID := src["id"].(string)
|
||||
var tree *parse.Tree
|
||||
if !isDetached {
|
||||
var loadErr error
|
||||
if nil != tx {
|
||||
tree, loadErr = tx.loadTree(id)
|
||||
tree, loadErr = tx.loadTree(srcID)
|
||||
} else {
|
||||
tree, loadErr = LoadTreeByBlockID(id)
|
||||
tree, loadErr = LoadTreeByBlockID(srcID)
|
||||
}
|
||||
if nil != loadErr {
|
||||
logging.LogErrorf("load tree [%s] failed: %s", id, err)
|
||||
logging.LogErrorf("load tree [%s] failed: %s", srcID, err)
|
||||
return loadErr
|
||||
}
|
||||
}
|
||||
|
||||
if avErr := addAttributeViewBlock(avID, blockID, previousBlockID, id, content, isDetached, ignoreFillFilter, tree, tx); nil != avErr {
|
||||
srcContent := src["content"].(string)
|
||||
if avErr := addAttributeViewBlock(avID, blockID, previousBlockID, srcID, srcContent, isDetached, ignoreFillFilter, tree, tx); nil != avErr {
|
||||
return avErr
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID, content string, isDetached, ignoreFillFilter bool, tree *parse.Tree, tx *Transaction) (err error) {
|
||||
func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID, addingBlockContent string, isDetached, ignoreFillFilter bool, tree *parse.Tree, tx *Transaction) (err error) {
|
||||
var node *ast.Node
|
||||
if !isDetached {
|
||||
node = treenode.GetNodeInTree(tree, addingBlockID)
|
||||
|
|
@ -2216,7 +2218,7 @@ func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID, conten
|
|||
}
|
||||
|
||||
if !isDetached {
|
||||
content = getNodeRefText(node)
|
||||
addingBlockContent = getNodeRefText(node)
|
||||
}
|
||||
|
||||
now := time.Now().UnixMilli()
|
||||
|
|
@ -2229,7 +2231,7 @@ func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID, conten
|
|||
// 重复绑定一下,比如剪切数据库块、取消绑定块后再次添加的场景需要
|
||||
bindBlockAv0(tx, avID, node, tree)
|
||||
blockValue.IsDetached = isDetached
|
||||
blockValue.Block.Content = content
|
||||
blockValue.Block.Content = addingBlockContent
|
||||
blockValue.UpdatedAt = now
|
||||
err = av.SaveAttributeView(attrView)
|
||||
}
|
||||
|
|
@ -2245,7 +2247,7 @@ func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID, conten
|
|||
IsDetached: isDetached,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
Block: &av.ValueBlock{ID: addingBlockID, Content: content, Created: now, Updated: now}}
|
||||
Block: &av.ValueBlock{ID: addingBlockID, Content: addingBlockContent, Created: now, Updated: now}}
|
||||
blockValues.Values = append(blockValues.Values, blockValue)
|
||||
|
||||
// 如果存在过滤条件,则将过滤条件应用到新添加的块上
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue