🎨 Automatically fill in the filter result value when adding rows in the database table view https://github.com/siyuan-note/siyuan/issues/9905
This commit is contained in:
parent
7ff4356316
commit
b206a1a570
1 changed files with 10 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue