mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
This commit is contained in:
parent
f7d28dc1de
commit
99cf987465
1 changed files with 19 additions and 1 deletions
|
@ -3030,6 +3030,24 @@ func addAttributeViewBlock(now int64, avID, blockID, groupID, previousBlockID, a
|
|||
} else {
|
||||
v.ItemIDs = append([]string{addingBlockID}, v.ItemIDs...)
|
||||
}
|
||||
|
||||
for _, g := range v.Groups {
|
||||
if "" != previousBlockID {
|
||||
changed := false
|
||||
for i, id := range g.GroupItemIDs {
|
||||
if id == previousBlockID {
|
||||
g.GroupItemIDs = append(g.GroupItemIDs[:i+1], append([]string{addingBlockID}, g.GroupItemIDs[i+1:]...)...)
|
||||
changed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !changed {
|
||||
g.GroupItemIDs = append(g.GroupItemIDs, addingBlockID)
|
||||
}
|
||||
} else {
|
||||
g.GroupItemIDs = append([]string{addingBlockID}, g.GroupItemIDs...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果存在分组条件,则将分组条件应用到新添加的块上
|
||||
|
@ -3159,7 +3177,7 @@ func removeAttributeViewBlock(srcIDs []string, avID string, tx *Transaction) (er
|
|||
|
||||
for _, groupView := range view.Groups {
|
||||
for _, blockID := range srcIDs {
|
||||
groupView.ItemIDs = gulu.Str.RemoveElem(groupView.ItemIDs, blockID)
|
||||
groupView.GroupItemIDs = gulu.Str.RemoveElem(groupView.GroupItemIDs, blockID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue