An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
Daniel0e8ce9ddf91f
diff --git a/kernel/av/av.go b/kernel/av/av.goindex f2ba48aa93..b536c3f451 100644--- a/kernel/av/av.go+++ b/kernel/av/av.go@@ -199,7 +199,7 @@ type View struct {GroupCalc *GroupCalc `json:"groupCalc,omitempty"` // 分组计算规则GroupName string `json:"groupName,omitempty"` // 分组名称GroupFolded bool `json:"groupFolded"` // 分组是否折叠- GroupHidden bool `json:"groupHidden"` // 分组是否隐藏+ GroupHidden int `json:"groupHidden"` // 分组是否隐藏,0:显示,1:空白隐藏,2:手动隐藏}// GroupCalc 描述了分组计算规则和结果的结构。@@ -290,7 +290,8 @@ type Viewable interface {SetGroupFolded(folded bool)// SetGroupHidden 设置分组是否隐藏。- SetGroupHidden(hidden bool)+ // hidden 0:显示,1:空白隐藏,2:手动隐藏+ SetGroupHidden(hidden int)}func NewAttributeView(id string) (ret *AttributeView) {diff --git a/kernel/av/layout.go b/kernel/av/layout.goindex fee969078b..2bf4d8dd34 100644--- a/kernel/av/layout.go+++ b/kernel/av/layout.go@@ -68,7 +68,7 @@ type BaseInstance struct {GroupCalc *GroupCalc `json:"groupCalc,omitempty"` // 分组计算规则和结果GroupName string `json:"groupName,omitempty"` // 分组名称GroupFolded bool `json:"groupFolded"` // 分组是否折叠- GroupHidden bool `json:"groupHidden"` // 分组是否隐藏+ GroupHidden int `json:"groupHidden"` // 分组是否隐藏,0:显示,1:空白隐藏,2:手动隐藏}func NewViewBaseInstance(view *View) *BaseInstance {@@ -127,7 +127,7 @@ func (baseInstance *BaseInstance) SetGroupFolded(folded bool) {baseInstance.GroupFolded = folded}-func (baseInstance *BaseInstance) SetGroupHidden(hidden bool) {+func (baseInstance *BaseInstance) SetGroupHidden(hidden int) {baseInstance.GroupHidden = hidden}diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 8cda256665..22c9428ae5 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -121,13 +121,13 @@ func syncAttrViewTableColWidth(operation *Operation) (err error) {}func (tx *Transaction) doHideAttrViewGroup(operation *Operation) (ret *TxErr) {- if err := hideAttributeViewGroup(operation.AvID, operation.BlockID, operation.ID, operation.Data.(bool)); nil != err {+ if err := hideAttributeViewGroup(operation.AvID, operation.BlockID, operation.ID, int(operation.Data.(float64))); nil != err {return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}}return}-func hideAttributeViewGroup(avID, blockID, groupID string, hidden bool) (err error) {+func hideAttributeViewGroup(avID, blockID, groupID string, hidden int) (err error) {attrView, err := av.ParseAttributeView(avID)if err != nil {return err@@ -186,8 +186,29 @@ func SetAttributeViewGroup(avID, blockID string, group *av.ViewGroup) (err errorreturn err}+ oldHideEmpty := false+ if nil != view.Group {+ oldHideEmpty = view.Group.HideEmpty+ }+view.Group = groupgenAttrViewViewGroups(view, attrView)++ if view.Group.HideEmpty != oldHideEmpty {+ for _, g := range view.Groups {+ if view.Group.HideEmpty {+ if 2 != g.GroupHidden && 1 > len(g.GroupItemIDs) {+ g.GroupHidden = 1+ }+ } else {+ if 2 != g.GroupHidden {+ g.GroupHidden = 0+ }+ }+ }+ }++ err = av.SaveAttributeView(attrView)return}@@ -1406,6 +1427,7 @@ func renderAttributeView(attrView *av.AttributeView, blockID, viewID, query striupdatedDate := time.UnixMilli(view.GroupUpdated).Format("2006-01-02")if time.Now().Format("2006-01-02") != updatedDate {genAttrViewViewGroups(view, attrView)+ av.SaveAttributeView(attrView)}for _, groupView := range view.Groups {@@ -1468,7 +1490,10 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {}// 如果是按日期分组,则需要记录每个分组视图的一些状态字段,以便后面重新计算分组后可以恢复这些状态- type GroupState struct{ Folded, Hidden bool }+ type GroupState struct {+ Folded bool+ Hidden int+ }groupStates := map[string]*GroupState{}if isGroupByDate(view) {for _, groupView := range view.Groups {@@ -1637,8 +1662,6 @@ func genAttrViewViewGroups(view *av.View, attrView *av.AttributeView) {}}}-- av.SaveAttributeView(attrView)}func isGroupByDate(view *av.View) bool {