Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Automatically fill in the filter result value when adding rows in the database table view https://github.com/siyuan-note/siyuan/issues/9905

Danielb206a1a57084
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 3f03154afb..dc8f114720 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -1104,18 +1104,26 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tre
content = getNodeRefText(node)
}
now := time.Now().UnixMilli()
- value := &av.Value{ID: ast.NewNodeID(), KeyID: blockValues.Key.ID, BlockID: blockID, Type: av.KeyTypeBlock, IsDetached: operation.IsDetached, IsInitialized: false, Block: &av.ValueBlock{ID: blockID, Content: content, Created: now, Updated: now}}
- blockValues.Values = append(blockValues.Values, value)
+ blockValue := &av.Value{ID: ast.NewNodeID(), KeyID: blockValues.Key.ID, BlockID: blockID, Type: av.KeyTypeBlock, IsDetached: operation.IsDetached, IsInitialized: false, Block: &av.ValueBlock{ID: blockID, Content: content, Created: now, Updated: now}}
+ blockValues.Values = append(blockValues.Values, blockValue)
// 如果存在过滤条件,则将过滤条件应用到新添加的块上
view, _ := attrView.GetCurrentView()
if nil != view && 0 < len(view.Table.Filters) {
viewable, _ := renderAttributeViewTable(attrView, view)
+ viewable.FilterRows()
+ viewable.SortRows()
+
if 0 < len(viewable.Rows) {
row := viewable.Rows[len(viewable.Rows)-1]
for _, filter := range view.Table.Filters {
for _, cell := range row.Cells {
if nil != cell.Value && cell.Value.KeyID == filter.Column {
+ if av.KeyTypeBlock == cell.ValueType {
+ blockValue.Block.Content = cell.Value.Block.Content
+ continue
+ }
+
newValue := cell.Value.Clone()
newValue.ID = ast.NewNodeID()
newValue.BlockID = blockID