Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2025-08-23 12:17:57 +08:00
commit 52fe742a8c
4 changed files with 18 additions and 9 deletions

View file

@ -345,7 +345,13 @@ func addAttributeViewBlocks(c *gin.Context) {
src := v.(map[string]interface{})
srcs = append(srcs, src)
}
err := model.AddAttributeViewBlock(nil, srcs, avID, blockID, groupID, previousID)
var ignoreDefaultFill bool
if nil != arg["ignoreDefaultFill"] {
ignoreDefaultFill = arg["ignoreDefaultFill"].(bool)
}
err := model.AddAttributeViewBlock(nil, srcs, avID, blockID, groupID, previousID, ignoreDefaultFill)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()

View file

@ -2957,14 +2957,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)
err := AddAttributeViewBlock(tx, operation.Srcs, operation.AvID, operation.BlockID, operation.GroupID, operation.PreviousID, operation.IgnoreDefaultFill)
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) (err error) {
func AddAttributeViewBlock(tx *Transaction, srcs []map[string]interface{}, avID, dbBlockID, groupID, previousItemID string, ignoreDefaultFill bool) (err error) {
slices.Reverse(srcs) // https://github.com/siyuan-note/siyuan/issues/11286
now := time.Now().UnixMilli()
@ -2998,14 +2998,14 @@ 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, srcID, srcContent, isDetached, tree, tx); nil != avErr {
if avErr := addAttributeViewBlock(now, avID, dbBlockID, groupID, previousItemID, srcItemID, srcID, srcContent, isDetached, ignoreDefaultFill, tree, tx); nil != avErr {
return avErr
}
}
return
}
func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID, addingItemID, addingBoundBlockID, addingBlockContent string, isDetached 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) (err error) {
var node *ast.Node
if !isDetached {
node = treenode.GetNodeInTree(tree, addingBoundBlockID)
@ -3079,7 +3079,9 @@ func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID,
groupView = view.GetGroupByID(groupID)
}
fillDefaultValue(attrView, view, groupView, previousItemID, addingItemID)
if !ignoreDefaultFill {
fillDefaultValue(attrView, view, groupView, previousItemID, addingItemID)
}
// 处理日期字段默认填充当前创建时间
// The database date field supports filling the current time by default https://github.com/siyuan-note/siyuan/issues/10823

View file

@ -991,7 +991,7 @@ func DuplicateDoc(tree *parse.Tree) {
AddAttributeViewBlock(nil, []map[string]interface{}{{
"id": n.ID,
"isDetached": false,
}}, avID, "", "", "")
}}, avID, "", "", "", false)
ReloadAttrView(avID)
}
return ast.WalkContinue

View file

@ -1099,7 +1099,7 @@ func (tx *Transaction) doLargeInsert(previousID string) (ret *TxErr) {
AddAttributeViewBlock(tx, []map[string]interface{}{{
"id": insertedNode.ID,
"isDetached": false,
}}, avID, "", "", previousID)
}}, avID, "", "", previousID, false)
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)
}}, avID, "", "", previousID, false)
ReloadAttrView(avID)
}
@ -1727,6 +1727,7 @@ type Operation struct {
Layout av.LayoutType `json:"layout"` // 属性视图布局类型
GroupID string `json:"groupID"` // 属性视图分组视图 ID
TargetGroupID string `json:"targetGroupID"` // 属性视图目标分组视图 ID
IgnoreDefaultFill bool `json:"ignoreDefaultFill"` // 是否忽略默认填充
}
type Transaction struct {