This commit is contained in:
Daniel 2025-08-08 18:18:44 +08:00
parent a01c44a03d
commit ec7ca366ba
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -415,11 +415,33 @@ func SetAttributeViewGroup(avID, blockID string, group *av.ViewGroup) (err error
return err return err
} }
oldHideEmpty := false
if nil != view.Group {
oldHideEmpty = view.Group.HideEmpty
}
groupStates := getAttrViewGroupStates(view) groupStates := getAttrViewGroupStates(view)
view.Group = group view.Group = group
regenAttrViewViewGroups(attrView, "force") regenAttrViewViewGroups(attrView, "force")
setAttrViewGroupStates(view, groupStates) setAttrViewGroupStates(view, groupStates)
if view.Group.HideEmpty != oldHideEmpty {
if !oldHideEmpty && view.Group.HideEmpty { // 启用隐藏空分组
for _, g := range view.Groups {
if g.GroupHidden == 0 && 1 > len(g.GroupItemIDs) {
g.GroupHidden = 1
}
}
}
if oldHideEmpty && !view.Group.HideEmpty { // 禁用隐藏空分组
for _, g := range view.Groups {
if g.GroupHidden == 1 && 1 > len(g.GroupItemIDs) {
g.GroupHidden = 0
}
}
}
}
err = av.SaveAttributeView(attrView) err = av.SaveAttributeView(attrView)
ReloadAttrView(avID) ReloadAttrView(avID)
return return