Skip to content

Commit e871f49

Browse files
committed
🎨 Improve av #15523
1 parent 31667b0 commit e871f49

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

kernel/av/av.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ type View struct {
200200
GroupVal *Value `json:"groupVal,omitempty"` // 分组值
201201
GroupFolded bool `json:"groupFolded"` // 分组是否折叠
202202
GroupHidden int `json:"groupHidden"` // 分组是否隐藏,0:显示,1:空白隐藏,2:手动隐藏
203-
GroupSort int `json:"groupSort"` // 分组排序值
203+
GroupSort int `json:"groupSort"` // 分组排序值,用于手动排序
204204
}
205205

206206
// GetGroupValue 获取分组视图的分组值。

kernel/model/attribute_view.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,11 +1742,11 @@ func genAttrViewGroups(view *av.View, attrView *av.AttributeView) {
17421742
v.GroupVal.MSelect = []*av.ValueSelect{{Content: opt.Name, Color: opt.Color}}
17431743
}
17441744
}
1745+
v.GroupSort = -1
17451746
view.Groups = append(view.Groups, v)
17461747
}
17471748

17481749
view.GroupCreated = time.Now().UnixMilli()
1749-
17501750
setAttrViewGroupStates(view, groupStates)
17511751
}
17521752

@@ -1784,6 +1784,26 @@ func setAttrViewGroupStates(view *av.View, groupStates map[string]*GroupState) {
17841784
groupView.GroupSort = state.Sort
17851785
}
17861786
}
1787+
1788+
defaultGroup := view.GetGroupByGroupValue(groupValueDefault)
1789+
if nil != defaultGroup {
1790+
if -1 == defaultGroup.GroupSort {
1791+
view.RemoveGroupByID(defaultGroup.ID)
1792+
} else {
1793+
defaultGroup = nil
1794+
}
1795+
}
1796+
1797+
for i, groupView := range view.Groups {
1798+
if i != groupView.GroupSort && -1 == groupView.GroupSort {
1799+
groupView.GroupSort = i
1800+
}
1801+
}
1802+
1803+
if nil != defaultGroup {
1804+
view.Groups = append(view.Groups, defaultGroup)
1805+
defaultGroup.GroupSort = len(view.Groups) - 1
1806+
}
17871807
}
17881808

17891809
func GetCurrentAttributeViewImages(avID, viewID, query string) (ret []string, err error) {

0 commit comments

Comments
 (0)