This commit is contained in:
Daniel 2025-07-25 22:09:03 +08:00
parent 2eadefed6f
commit 9cf009d9d9
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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 {