An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Automatically fill in the filter result value when adding rows in the database table view https://github.com/siyuan-note/siyuan/issues/9905
Danielfcd134ad2d3d
diff --git a/kernel/av/table.go b/kernel/av/table.goindex 66b2977574..fabba724bc 100644--- a/kernel/av/table.go+++ b/kernel/av/table.go@@ -727,7 +727,7 @@ func (table *Table) FilterRows() {rows := []*TableRow{}for _, row := range table.Rows {block := row.GetBlockValue()- if !block.IsInitialized && nil != block.Block && "" == block.Block.Content && block.IsDetached {+ if block.NotAffectFilter() {rows = append(rows, row)continue}diff --git a/kernel/av/value.go b/kernel/av/value.goindex 7be46a3f18..b90d63641f 100644--- a/kernel/av/value.go+++ b/kernel/av/value.go@@ -54,6 +54,10 @@ type Value struct {Rollup *ValueRollup `json:"rollup,omitempty"`}+func (value *Value) NotAffectFilter() bool {+ return !value.IsInitialized && nil != value.Block && "" == value.Block.Content && value.IsDetached+}+func (value *Value) String() string {switch value.Type {case KeyTypeBlock:diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex a7babed7db..fbcf323564 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -1114,22 +1114,24 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Treviewable.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- }+ row := GetLastSortRow(viewable.Rows)+ if nil != row {+ 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- newValue.IsDetached = operation.IsDetached- newValue.IsInitialized = false- values, _ := attrView.GetKeyValues(filter.Column)- values.Values = append(values.Values, newValue)+ newValue := cell.Value.Clone()+ newValue.ID = ast.NewNodeID()+ newValue.BlockID = blockID+ newValue.IsDetached = operation.IsDetached+ newValue.IsInitialized = false+ values, _ := attrView.GetKeyValues(filter.Column)+ values.Values = append(values.Values, newValue)+ }}}}@@ -1178,6 +1180,17 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Trereturn}+func GetLastSortRow(rows []*av.TableRow) *av.TableRow {+ for i := len(rows) - 1; i >= 0; i-- {+ row := rows[i]+ block := row.GetBlockValue()+ if !block.NotAffectFilter() {+ return row+ }+ }+ return nil+}+func (tx *Transaction) doRemoveAttrViewBlock(operation *Operation) (ret *TxErr) {err := tx.removeAttributeViewBlock(operation)if nil != err {