mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 18:10:12 +01:00
🎨 Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
This commit is contained in:
parent
54f2d8599e
commit
684286fc8a
4 changed files with 26 additions and 19 deletions
|
|
@ -199,7 +199,6 @@ type View struct {
|
|||
GroupName string `json:"groupName,omitempty"` // 分组名称
|
||||
GroupFolded bool `json:"groupFolded,omitempty"` // 分组是否折叠
|
||||
GroupHidden bool `json:"groupHidden,omitempty"` // 分组是否隐藏
|
||||
GroupHideEmpty bool `json:"groupHideEmpty,omitempty"` // 分组是否隐藏空分组
|
||||
}
|
||||
|
||||
// GroupCalc 描述了分组计算规则和结果的结构。
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ type ViewGroup struct {
|
|||
Method GroupMethod `json:"method"` // 分组方式
|
||||
Range *GroupRange `json:"range,omitempty"` // 分组范围
|
||||
Order GroupOrder `json:"order"` // 分组排序规则
|
||||
HideEmpty bool `json:"hideEmpty,omitempty"` // 是否隐藏空分组
|
||||
}
|
||||
|
||||
// GroupMethod 描述了分组方式。
|
||||
|
|
|
|||
|
|
@ -93,14 +93,14 @@ func syncAttrViewTableColWidth(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetGroupHideEmpty(operation *Operation) (ret *TxErr) {
|
||||
if err := SetGroupHideEmpty(operation.AvID, operation.BlockID, operation.Data.(bool)); nil != err {
|
||||
func (tx *Transaction) doSetAttrViewHideEmptyGroup(operation *Operation) (ret *TxErr) {
|
||||
if err := setAttrViewHideEmptyGroup(operation.AvID, operation.BlockID, operation.Data.(bool)); nil != err {
|
||||
return &TxErr{code: TxErrHandleAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func SetGroupHideEmpty(avID, blockID string, hidden bool) (err error) {
|
||||
func setAttrViewHideEmptyGroup(avID, blockID string, hidden bool) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -115,7 +115,14 @@ func SetGroupHideEmpty(avID, blockID string, hidden bool) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
view.GroupHideEmpty = hidden
|
||||
view.Group.HideEmpty = hidden
|
||||
for _, group := range view.Groups {
|
||||
if hidden {
|
||||
group.GroupHidden = true
|
||||
} else {
|
||||
group.GroupHidden = false
|
||||
}
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -301,8 +301,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
ret = tx.doSetAttrViewGroup(op)
|
||||
case "hideAttrViewGroup":
|
||||
ret = tx.doHideAttrViewGroup(op)
|
||||
case "setGroupHideEmpty":
|
||||
ret = tx.doSetGroupHideEmpty(op)
|
||||
case "setAttrViewHideEmptyGroup":
|
||||
ret = tx.doSetAttrViewHideEmptyGroup(op)
|
||||
case "syncAttrViewTableColWidth":
|
||||
ret = tx.doSyncAttrViewTableColWidth(op)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue