mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-07 09:18:49 +01:00
🎨 Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
This commit is contained in:
parent
2eadefed6f
commit
9cf009d9d9
1 changed files with 33 additions and 0 deletions
|
|
@ -4290,6 +4290,10 @@ func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID
|
|||
}
|
||||
val.SetUpdatedAt(now)
|
||||
|
||||
if err = regenAttrViewViewGroups(attrView, keyID); nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
if nil != key && av.KeyTypeRelation == key.Type && nil != key.Relation && key.Relation.IsTwoWay {
|
||||
// 双向关联需要同时更新目标字段的值
|
||||
|
||||
|
|
@ -4345,6 +4349,9 @@ func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID
|
|||
if value.BlockID == blockID {
|
||||
value.Relation.BlockIDs = gulu.Str.RemoveElem(value.Relation.BlockIDs, rowID)
|
||||
value.SetUpdatedAt(now)
|
||||
if err = regenAttrViewViewGroups(destAv, key.Relation.BackKeyID); nil != err {
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -4360,6 +4367,32 @@ func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID
|
|||
return
|
||||
}
|
||||
|
||||
func regenAttrViewViewGroups(attrView *av.AttributeView, keyID string) (err error) {
|
||||
for _, view := range attrView.Views {
|
||||
if nil != view.Group && view.Group.Field == keyID {
|
||||
groupKey, _ := attrView.GetKey(view.Group.Field)
|
||||
if nil == groupKey {
|
||||
return
|
||||
}
|
||||
|
||||
genAttrViewViewGroups(view, attrView)
|
||||
|
||||
for _, g := range view.Groups {
|
||||
if view.Group.HideEmpty {
|
||||
if 2 != g.GroupHidden && 1 > len(g.GroupItemIDs) {
|
||||
g.GroupHidden = 1
|
||||
}
|
||||
} else {
|
||||
if 2 != g.GroupHidden {
|
||||
g.GroupHidden = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func unbindBlockAv(tx *Transaction, avID, blockID string) {
|
||||
node, tree, err := getNodeByBlockID(tx, blockID)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue