mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Improve av https://github.com/siyuan-note/siyuan/issues/15499
This commit is contained in:
parent
8ca9f119d0
commit
a9c2ae7351
5 changed files with 35 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue