mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-20 14:04:06 +01:00
This commit is contained in:
parent
7e6752a8fb
commit
d0f350d215
17 changed files with 41 additions and 21 deletions
|
|
@ -351,7 +351,7 @@ func addAttributeViewBlocks(c *gin.Context) {
|
|||
ignoreDefaultFill = arg["ignoreDefaultFill"].(bool)
|
||||
}
|
||||
|
||||
err := model.AddAttributeViewBlock(nil, srcs, avID, blockID, groupID, previousID, ignoreDefaultFill)
|
||||
err := model.AddAttributeViewBlock(nil, srcs, avID, blockID, groupID, previousID, ignoreDefaultFill, nil)
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
|
|||
|
|
@ -2958,14 +2958,14 @@ func setAttributeViewColumnCalc(operation *Operation) (err error) {
|
|||
}
|
||||
|
||||
func (tx *Transaction) doInsertAttrViewBlock(operation *Operation) (ret *TxErr) {
|
||||
err := AddAttributeViewBlock(tx, operation.Srcs, operation.AvID, operation.BlockID, operation.GroupID, operation.PreviousID, operation.IgnoreDefaultFill)
|
||||
err := AddAttributeViewBlock(tx, operation.Srcs, operation.AvID, operation.BlockID, operation.GroupID, operation.PreviousID, operation.IgnoreDefaultFill, operation.Context)
|
||||
if err != nil {
|
||||
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func AddAttributeViewBlock(tx *Transaction, srcs []map[string]interface{}, avID, dbBlockID, groupID, previousItemID string, ignoreDefaultFill bool) (err error) {
|
||||
func AddAttributeViewBlock(tx *Transaction, srcs []map[string]interface{}, avID, dbBlockID, groupID, previousItemID string, ignoreDefaultFill bool, context map[string]interface{}) (err error) {
|
||||
slices.Reverse(srcs) // https://github.com/siyuan-note/siyuan/issues/11286
|
||||
|
||||
now := time.Now().UnixMilli()
|
||||
|
|
@ -3000,14 +3000,18 @@ func AddAttributeViewBlock(tx *Transaction, srcs []map[string]interface{}, avID,
|
|||
if nil != src["content"] {
|
||||
srcContent = src["content"].(string)
|
||||
}
|
||||
if avErr := addAttributeViewBlock(now, avID, dbBlockID, groupID, previousItemID, srcItemID, boundBlockID, srcContent, isDetached, ignoreDefaultFill, tree, tx); nil != avErr {
|
||||
if avErr := addAttributeViewBlock(now, avID, dbBlockID, groupID, previousItemID, srcItemID, boundBlockID, srcContent, isDetached, ignoreDefaultFill, tree, tx, context); nil != avErr {
|
||||
return avErr
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID, addingItemID, addingBoundBlockID, addingBlockContent string, isDetached, ignoreDefaultFill bool, tree *parse.Tree, tx *Transaction) (err error) {
|
||||
func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID, addingItemID, addingBoundBlockID, addingBlockContent string, isDetached, ignoreDefaultFill bool, tree *parse.Tree, tx *Transaction, context map[string]interface{}) (err error) {
|
||||
if nil == context {
|
||||
context = map[string]any{}
|
||||
}
|
||||
|
||||
var node *ast.Node
|
||||
if !isDetached {
|
||||
node = treenode.GetNodeInTree(tree, addingBoundBlockID)
|
||||
|
|
@ -3051,6 +3055,9 @@ func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID,
|
|||
blockValue.UpdatedAt = now
|
||||
err = av.SaveAttributeView(attrView)
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf(Conf.language(269), attrView.Name)
|
||||
context["message"] = msg
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -991,7 +991,7 @@ func DuplicateDoc(tree *parse.Tree) {
|
|||
AddAttributeViewBlock(nil, []map[string]interface{}{{
|
||||
"id": n.ID,
|
||||
"isDetached": false,
|
||||
}}, avID, "", "", "", false)
|
||||
}}, avID, "", "", "", false, nil)
|
||||
ReloadAttrView(avID)
|
||||
}
|
||||
return ast.WalkContinue
|
||||
|
|
|
|||
|
|
@ -1099,7 +1099,7 @@ func (tx *Transaction) doLargeInsert(previousID string) (ret *TxErr) {
|
|||
AddAttributeViewBlock(tx, []map[string]interface{}{{
|
||||
"id": insertedNode.ID,
|
||||
"isDetached": false,
|
||||
}}, avID, "", "", previousID, false)
|
||||
}}, avID, "", "", previousID, false, nil)
|
||||
ReloadAttrView(avID)
|
||||
}
|
||||
|
||||
|
|
@ -1284,7 +1284,7 @@ func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {
|
|||
AddAttributeViewBlock(tx, []map[string]interface{}{{
|
||||
"id": insertedNode.ID,
|
||||
"isDetached": false,
|
||||
}}, avID, "", "", previousID, false)
|
||||
}}, avID, "", "", previousID, false, nil)
|
||||
ReloadAttrView(avID)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue