mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Improve database template field grouping https://github.com/siyuan-note/siyuan/issues/15687
This commit is contained in:
parent
afdd605dd1
commit
2de55d2e63
1 changed files with 21 additions and 3 deletions
|
|
@ -88,6 +88,11 @@ func renderAttributeView(attrView *av.AttributeView, nodeID, viewID, query strin
|
|||
}
|
||||
|
||||
func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView, view *av.View, query string, page, pageSize int, groupPaging map[string]interface{}) (err error) {
|
||||
groupKey := view.GetGroupKey(attrView)
|
||||
if nil == groupKey {
|
||||
return
|
||||
}
|
||||
|
||||
// 当前日期可能会变,所以如果是按日期分组则需要重新生成分组
|
||||
if isGroupByDate(view) {
|
||||
createdDate := time.UnixMilli(view.GroupCreated).Format("2006-01-02")
|
||||
|
|
@ -97,9 +102,10 @@ func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView,
|
|||
}
|
||||
}
|
||||
|
||||
groupKey := view.GetGroupKey(attrView)
|
||||
if nil == groupKey {
|
||||
return
|
||||
// 如果是按模板分组则需要重新生成分组
|
||||
if isGroupByTemplate(attrView, view) {
|
||||
regenAttrViewGroups(attrView)
|
||||
av.SaveAttributeView(attrView)
|
||||
}
|
||||
|
||||
// 如果存在分组的话渲染分组视图
|
||||
|
|
@ -352,6 +358,18 @@ func isGroupByDate(view *av.View) bool {
|
|||
return av.GroupMethodDateDay == view.Group.Method || av.GroupMethodDateWeek == view.Group.Method || av.GroupMethodDateMonth == view.Group.Method || av.GroupMethodDateYear == view.Group.Method || av.GroupMethodDateRelative == view.Group.Method
|
||||
}
|
||||
|
||||
func isGroupByTemplate(attrView *av.AttributeView, view *av.View) bool {
|
||||
if nil == view.Group {
|
||||
return false
|
||||
}
|
||||
|
||||
groupKey := view.GetGroupKey(attrView)
|
||||
if nil == groupKey {
|
||||
return false
|
||||
}
|
||||
return av.KeyTypeTemplate == groupKey.Type
|
||||
}
|
||||
|
||||
func renderViewableInstance(viewable av.Viewable, view *av.View, attrView *av.AttributeView, page, pageSize int) (err error) {
|
||||
if nil == viewable {
|
||||
err = av.ErrViewNotFound
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue