mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-23 16:56:10 +01:00
✨ Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
This commit is contained in:
parent
b357047290
commit
17c59cb2ca
11 changed files with 64 additions and 69 deletions
|
|
@ -191,12 +191,13 @@ type View struct {
|
|||
Table *LayoutTable `json:"table,omitempty"` // 表格布局
|
||||
Gallery *LayoutGallery `json:"gallery,omitempty"` // 画廊布局
|
||||
|
||||
Groups []*View `json:"groups,omitempty"` // 分组视图列表
|
||||
GroupCalcSum bool `json:"groupCalcSum,omitempty"` // 分组是否计算总和
|
||||
GroupName string `json:"groupName,omitempty"` // 分组名称
|
||||
GroupFolded bool `json:"groupFolded,omitempty"` // 分组是否折叠
|
||||
GroupHidden bool `json:"groupHidden,omitempty"` // 分组是否隐藏
|
||||
GroupDefault bool `json:"groupDefault,omitempty"` // 是否为默认分组
|
||||
Groups []*View `json:"groups,omitempty"` // 分组视图列表
|
||||
GroupItemIDs []string `json:"groupItemIds,omitempty"` // 分组项目 ID 列表,用于维护分组中的所有项目
|
||||
GroupCalcSum bool `json:"groupCalcSum,omitempty"` // 分组是否计算总和
|
||||
GroupName string `json:"groupName,omitempty"` // 分组名称
|
||||
GroupFolded bool `json:"groupFolded,omitempty"` // 分组是否折叠
|
||||
GroupHidden bool `json:"groupHidden,omitempty"` // 分组是否隐藏
|
||||
GroupDefault bool `json:"groupDefault,omitempty"` // 是否为默认分组
|
||||
}
|
||||
|
||||
// LayoutType 描述了视图布局类型。
|
||||
|
|
@ -252,12 +253,24 @@ func NewGalleryView() (ret *View) {
|
|||
|
||||
// Viewable 描述了视图的接口。
|
||||
type Viewable interface {
|
||||
Filterable
|
||||
Sortable
|
||||
Calculable
|
||||
|
||||
// Filter 根据视图中设置的过滤器进行过滤。
|
||||
Filter(attrView *AttributeView)
|
||||
|
||||
// Sort 根据视图中设置的排序规则进行排序。
|
||||
Sort(attrView *AttributeView)
|
||||
|
||||
// Calc 根据视图中设置的计算规则进行计算。
|
||||
Calc()
|
||||
|
||||
// GetType 获取视图的布局类型。
|
||||
GetType() LayoutType
|
||||
|
||||
// GetID 获取视图的 ID。
|
||||
GetID() string
|
||||
|
||||
// SetGroups 设置视图分组列表。
|
||||
SetGroups(viewables []Viewable)
|
||||
}
|
||||
|
||||
func NewAttributeView(id string) (ret *AttributeView) {
|
||||
|
|
|
|||
|
|
@ -16,13 +16,6 @@
|
|||
|
||||
package av
|
||||
|
||||
// Calculable 接口定义了可计算的视图类型。
|
||||
type Calculable interface {
|
||||
|
||||
// Calc 根据视图中设置的计算规则进行计算。
|
||||
Calc()
|
||||
}
|
||||
|
||||
// ColumnCalc 描述了列(字段)计算操作和结果的结构。
|
||||
type ColumnCalc struct {
|
||||
Operator CalcOperator `json:"operator"` // 计算操作符
|
||||
|
|
|
|||
|
|
@ -24,13 +24,6 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
// Filterable 接口定义了可过滤的视图类型。
|
||||
type Filterable interface {
|
||||
|
||||
// Filter 根据视图中设置的过滤器进行过滤。
|
||||
Filter(attrView *AttributeView)
|
||||
}
|
||||
|
||||
// ViewFilter 描述了视图过滤器的结构。
|
||||
type ViewFilter struct {
|
||||
Column string `json:"column"` // 列(字段)ID
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ type BaseInstance struct {
|
|||
WrapField bool `json:"wrapField"` // 是否换行字段内容
|
||||
Folded bool `json:"folded,omitempty"` // 是否折叠
|
||||
Hidden bool `json:"hidden,omitempty"` // 是否隐藏
|
||||
|
||||
Groups []Viewable `json:"groups,omitempty"` // 分组实例列表
|
||||
}
|
||||
|
||||
func (baseInstance *BaseInstance) GetSorts() []*ViewSort {
|
||||
|
|
@ -76,6 +78,14 @@ func (baseInstance *BaseInstance) GetFilters() []*ViewFilter {
|
|||
return baseInstance.Filters
|
||||
}
|
||||
|
||||
func (baseInstance *BaseInstance) SetGroups(viewables []Viewable) {
|
||||
baseInstance.Groups = viewables
|
||||
}
|
||||
|
||||
func (baseInstance *BaseInstance) GetID() string {
|
||||
return baseInstance.ID
|
||||
}
|
||||
|
||||
// BaseInstanceField 描述了实例字段的基础结构。
|
||||
type BaseInstanceField struct {
|
||||
ID string `json:"id"` // ID
|
||||
|
|
|
|||
|
|
@ -97,8 +97,6 @@ type Gallery struct {
|
|||
Fields []*GalleryField `json:"fields"` // 画廊字段
|
||||
Cards []*GalleryCard `json:"cards"` // 画廊卡片
|
||||
CardCount int `json:"cardCount"` // 画廊总卡片数
|
||||
|
||||
Groups []*Gallery `json:"groups,omitempty"` // 分组实例列表
|
||||
}
|
||||
|
||||
// GalleryCard 描述了画廊实例卡片的结构。
|
||||
|
|
@ -179,10 +177,6 @@ func (gallery *Gallery) GetType() LayoutType {
|
|||
return LayoutTypeGallery
|
||||
}
|
||||
|
||||
func (gallery *Gallery) GetID() string {
|
||||
return gallery.ID
|
||||
}
|
||||
|
||||
func (gallery *Gallery) Sort(attrView *AttributeView) {
|
||||
sort0(gallery, attrView)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,8 +58,6 @@ type Table struct {
|
|||
Columns []*TableColumn `json:"columns"` // 表格列
|
||||
Rows []*TableRow `json:"rows"` // 表格行
|
||||
RowCount int `json:"rowCount"` // 表格总行数
|
||||
|
||||
Groups []*Table `json:"groups,omitempty"` // 分组实例列表
|
||||
}
|
||||
|
||||
// TableColumn 描述了表格实例列的结构。
|
||||
|
|
|
|||
|
|
@ -24,13 +24,6 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
// Sortable 接口定义了可排序的视图类型。
|
||||
type Sortable interface {
|
||||
|
||||
// Sort 根据视图中设置的排序规则进行排序。
|
||||
Sort(attrView *AttributeView)
|
||||
}
|
||||
|
||||
// ViewSort 描述了视图排序规则的结构。
|
||||
type ViewSort struct {
|
||||
Column string `json:"column"` // 列(字段)ID
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue