mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
🎨 Improve Add to Database https://github.com/siyuan-note/siyuan/issues/10659
This commit is contained in:
parent
8aa8ad65f8
commit
005ae241e9
4 changed files with 18 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue