Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2025-08-09 17:37:08 +08:00
commit 8754e8e5fd
5 changed files with 35 additions and 0 deletions

View file

@ -349,6 +349,10 @@ type Viewable interface {
// SetGroupFolded 设置分组是否折叠。
SetGroupFolded(folded bool)
// GetGroupHidden 获取分组是否隐藏。
// hidden 0显示1空白隐藏2手动隐藏
GetGroupHidden() int
// SetGroupHidden 设置分组是否隐藏。
// hidden 0显示1空白隐藏2手动隐藏
SetGroupHidden(hidden int)

View file

@ -123,6 +123,10 @@ func (baseInstance *BaseInstance) SetGroupFolded(folded bool) {
baseInstance.GroupFolded = folded
}
func (baseInstance *BaseInstance) GetGroupHidden() int {
return baseInstance.GroupHidden
}
func (baseInstance *BaseInstance) SetGroupHidden(hidden int) {
baseInstance.GroupHidden = hidden
}
@ -182,6 +186,9 @@ type Collection interface {
// SetItems 设置集合中的项目。
SetItems(items []Item)
// CountItems 返回集合中的项目数量。
CountItems() int
// GetFields 返回集合的所有字段。
GetFields() []Field

View file

@ -167,6 +167,10 @@ func (gallery *Gallery) SetItems(items []Item) {
}
}
func (gallery *Gallery) CountItems() int {
return len(gallery.Cards)
}
func (gallery *Gallery) GetFields() (ret []Field) {
ret = []Field{}
for _, field := range gallery.Fields {

View file

@ -141,6 +141,10 @@ func (table *Table) SetItems(items []Item) {
}
}
func (table *Table) CountItems() int {
return len(table.Rows)
}
func (table *Table) GetFields() (ret []Field) {
ret = []Field{}
for _, column := range table.Columns {

View file

@ -162,6 +162,8 @@ func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView,
if nil != err {
return
}
hideEmptyGroupViews(view, groupViewable)
groups = append(groups, groupViewable)
// 将分组视图的分组字段清空,减少冗余(字段信息可以在总的视图 view 对象上获取到)
@ -179,6 +181,20 @@ func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView,
return
}
func hideEmptyGroupViews(view *av.View, viewable av.Viewable) {
if nil == view.Group {
return
}
if !view.Group.HideEmpty {
return
}
if 2 != viewable.GetGroupHidden() && 1 > viewable.(av.Collection).CountItems() {
viewable.SetGroupHidden(1)
}
}
func sortGroupViews(todayStart time.Time, view *av.View) {
if av.GroupOrderMan == view.Group.Order {
sort.Slice(view.Groups, func(i, j int) bool { return view.Groups[i].GroupSort < view.Groups[j].GroupSort })