mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-14 19:18:06 +01:00
🎨 Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
This commit is contained in:
parent
759c12be06
commit
cff71aa720
7 changed files with 139 additions and 72 deletions
|
|
@ -192,14 +192,31 @@ type View struct {
|
|||
Gallery *LayoutGallery `json:"gallery,omitempty"` // 卡片布局
|
||||
ItemIDs []string `json:"itemIds,omitempty"` // 项目 ID 列表,用于维护所有项目
|
||||
|
||||
Group *ViewGroup `json:"group,omitempty"` // 分组规则
|
||||
GroupUpdated int64 `json:"groupUpdated"` // 分组规则更新时间戳
|
||||
Groups []*View `json:"groups,omitempty"` // 分组视图列表
|
||||
GroupItemIDs []string `json:"groupItemIds"` // 分组项目 ID 列表,用于维护分组中的所有项目
|
||||
GroupCalc *GroupCalc `json:"groupCalc,omitempty"` // 分组计算规则
|
||||
GroupName string `json:"groupName,omitempty"` // 分组名称
|
||||
GroupFolded bool `json:"groupFolded"` // 分组是否折叠
|
||||
GroupHidden int `json:"groupHidden"` // 分组是否隐藏,0:显示,1:空白隐藏,2:手动隐藏
|
||||
Group *ViewGroup `json:"group,omitempty"` // 分组规则
|
||||
GroupUpdated int64 `json:"groupUpdated"` // 分组规则更新时间戳
|
||||
Groups []*View `json:"groups,omitempty"` // 分组视图列表
|
||||
GroupItemIDs []string `json:"groupItemIds"` // 分组项目 ID 列表,用于维护分组中的所有项目
|
||||
GroupCalc *GroupCalc `json:"groupCalc,omitempty"` // 分组计算规则
|
||||
GroupValue string `json:"groupValue,omitempty"` // 分组值
|
||||
GroupFolded bool `json:"groupFolded"` // 分组是否折叠
|
||||
GroupHidden int `json:"groupHidden"` // 分组是否隐藏,0:显示,1:空白隐藏,2:手动隐藏
|
||||
}
|
||||
|
||||
const (
|
||||
GroupValueDefault = "_@default@_" // 默认分组值(值为空的默认分组)
|
||||
GroupValueNotInRange = "_@notInRange@_" // 不再范围内的分组值(只有数字类型的分组才可能是该值)
|
||||
)
|
||||
|
||||
// GetGroup 获取指定分组 ID 的分组视图。
|
||||
func (view *View) GetGroup(groupID string) *View {
|
||||
if nil == view.Groups {
|
||||
return nil
|
||||
}
|
||||
for _, group := range view.Groups {
|
||||
if group.ID == groupID {
|
||||
return group
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GroupCalc 描述了分组计算规则和结果的结构。
|
||||
|
|
@ -283,9 +300,6 @@ type Viewable interface {
|
|||
// GetGroupCalc 获取视图分组计算规则和结果。
|
||||
GetGroupCalc() *GroupCalc
|
||||
|
||||
// SetGroupName 设置分组名称。
|
||||
SetGroupName(name string)
|
||||
|
||||
// SetGroupFolded 设置分组是否折叠。
|
||||
SetGroupFolded(folded bool)
|
||||
|
||||
|
|
|
|||
|
|
@ -866,8 +866,8 @@ func (filter *ViewFilter) GetAffectValue(key *Key, defaultVal *Value) (ret *Valu
|
|||
return
|
||||
}
|
||||
}
|
||||
// 没有默认值则使用过滤条件的值
|
||||
|
||||
// 没有默认值则使用过滤条件的值
|
||||
switch filter.Value.Type {
|
||||
case KeyTypeBlock:
|
||||
switch filter.Operator {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ type BaseInstance struct {
|
|||
|
||||
Groups []Viewable `json:"groups,omitempty"` // 分组实例列表
|
||||
GroupCalc *GroupCalc `json:"groupCalc,omitempty"` // 分组计算规则和结果
|
||||
GroupName string `json:"groupName,omitempty"` // 分组名称
|
||||
GroupFolded bool `json:"groupFolded"` // 分组是否折叠
|
||||
GroupHidden int `json:"groupHidden"` // 分组是否隐藏,0:显示,1:空白隐藏,2:手动隐藏
|
||||
}
|
||||
|
|
@ -91,7 +90,6 @@ func NewViewBaseInstance(view *View) *BaseInstance {
|
|||
Sorts: view.Sorts,
|
||||
Group: view.Group,
|
||||
GroupCalc: view.GroupCalc,
|
||||
GroupName: view.GroupName,
|
||||
GroupFolded: view.GroupFolded,
|
||||
GroupHidden: view.GroupHidden,
|
||||
ShowIcon: showIcon,
|
||||
|
|
@ -119,10 +117,6 @@ func (baseInstance *BaseInstance) GetGroupCalc() *GroupCalc {
|
|||
return baseInstance.GroupCalc
|
||||
}
|
||||
|
||||
func (baseInstance *BaseInstance) SetGroupName(name string) {
|
||||
baseInstance.GroupName = name
|
||||
}
|
||||
|
||||
func (baseInstance *BaseInstance) SetGroupFolded(folded bool) {
|
||||
baseInstance.GroupFolded = folded
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue