From 63914488f053d5350c78ca808ab6172470192963 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 14 Mar 2024 10:58:49 +0800 Subject: [PATCH] :art: `Add to Database` no longer autofills filter values https://github.com/siyuan-note/siyuan/issues/10587 --- kernel/api/av.go | 6 +++++- kernel/model/attribute_view.go | 10 +++++----- kernel/model/transaction.go | 21 +++++++++++---------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/kernel/api/av.go b/kernel/api/av.go index 687c4f831..36c648ece 100644 --- a/kernel/api/av.go +++ b/kernel/api/av.go @@ -122,8 +122,12 @@ func addAttributeViewValues(c *gin.Context) { previousID = arg["previousID"].(string) } isDetached := arg["isDetached"].(bool) + ignoreFillFilter := true + if nil != arg["ignoreFillFilter"] { + ignoreFillFilter = arg["ignoreFillFilter"].(bool) + } - err := model.AddAttributeViewBlock(nil, srcIDs, avID, blockID, previousID, isDetached) + err := model.AddAttributeViewBlock(nil, srcIDs, avID, blockID, previousID, isDetached, ignoreFillFilter) if nil != err { ret.Code = -1 ret.Msg = err.Error() diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 7d2364b00..42b55b75b 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -1925,14 +1925,14 @@ 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.IsDetached) + err := AddAttributeViewBlock(tx, operation.SrcIDs, 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 string, isDetached bool) (err error) { +func AddAttributeViewBlock(tx *Transaction, srcIDs []string, avID, blockID, previousBlockID string, isDetached, ignoreFillFilter bool) (err error) { for _, id := range srcIDs { var tree *parse.Tree if !isDetached { @@ -1948,14 +1948,14 @@ func AddAttributeViewBlock(tx *Transaction, srcIDs []string, avID, blockID, prev } } - if avErr := addAttributeViewBlock(avID, blockID, previousBlockID, id, isDetached, tree, tx); nil != avErr { + if avErr := addAttributeViewBlock(avID, blockID, previousBlockID, id, isDetached, ignoreFillFilter, tree, tx); nil != avErr { return avErr } } return } -func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID string, isDetached bool, tree *parse.Tree, tx *Transaction) (err error) { +func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID string, isDetached, ignoreFillFilter bool, tree *parse.Tree, tx *Transaction) (err error) { var node *ast.Node if !isDetached { node = treenode.GetNodeInTree(tree, addingBlockID) @@ -2006,7 +2006,7 @@ func addAttributeViewBlock(avID, blockID, previousBlockID, addingBlockID string, // 如果存在过滤条件,则将过滤条件应用到新添加的块上 view, _ := getAttrViewViewByBlockID(attrView, blockID) - if nil != view && 0 < len(view.Table.Filters) { + if nil != view && 0 < len(view.Table.Filters) && !ignoreFillFilter { viewable, _ := renderAttributeViewTable(attrView, view, "") viewable.FilterRows(attrView) viewable.SortRows() diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 1029b18e4..88c356d2e 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1231,16 +1231,17 @@ type Operation struct { DeckID string `json:"deckID"` // 用于添加/删除闪卡 - AvID string `json:"avID"` // 属性视图 ID - SrcIDs []string `json:"srcIDs"` // 用于将块拖拽到属性视图中 - IsDetached bool `json:"isDetached"` // 用于标识是否是脱离块,仅存在于属性视图中 - Name string `json:"name"` // 属性视图列名 - Typ string `json:"type"` // 属性视图列类型 - Format string `json:"format"` // 属性视图列格式化 - KeyID string `json:"keyID"` // 属性视列 ID - RowID string `json:"rowID"` // 属性视图行 ID - IsTwoWay bool `json:"isTwoWay"` // 属性视图关联列是否是双向关系 - BackRelationKeyID string `json:"backRelationKeyID"` // 属性视图关联列回链关联列的 ID + AvID string `json:"avID"` // 属性视图 ID + SrcIDs []string `json:"srcIDs"` // 用于将块拖拽到属性视图中 + IsDetached bool `json:"isDetached"` // 用于标识是否未绑定块,仅存在于属性视图中 + IgnoreFillFilterVal bool `json:"ignoreFillFilter"` // 用于标识是否忽略填充筛选值 + Name string `json:"name"` // 属性视图列名 + Typ string `json:"type"` // 属性视图列类型 + Format string `json:"format"` // 属性视图列格式化 + KeyID string `json:"keyID"` // 属性视列 ID + RowID string `json:"rowID"` // 属性视图行 ID + IsTwoWay bool `json:"isTwoWay"` // 属性视图关联列是否是双向关系 + BackRelationKeyID string `json:"backRelationKeyID"` // 属性视图关联列回链关联列的 ID } type Transaction struct {