mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
✨ Database grouping by field https://github.com/siyuan-note/siyuan/issues/10964
This commit is contained in:
parent
b77f3907f7
commit
276ea42188
5 changed files with 27 additions and 13 deletions
|
@ -185,8 +185,8 @@ type View struct {
|
|||
Desc string `json:"desc"` // 视图描述
|
||||
Filters []*ViewFilter `json:"filters,omitempty"` // 过滤规则
|
||||
Sorts []*ViewSort `json:"sorts,omitempty"` // 排序规则
|
||||
Group *ViewGroup `json:"group,omitempty"` // 分组规则
|
||||
PageSize int `json:"pageSize"` // 每页条目数
|
||||
|
||||
LayoutType LayoutType `json:"type"` // 当前布局类型
|
||||
Table *LayoutTable `json:"table,omitempty"` // 表格布局
|
||||
Gallery *LayoutGallery `json:"gallery,omitempty"` // 画廊布局
|
||||
|
@ -585,6 +585,10 @@ func (av *AttributeView) Clone() (ret *AttributeView) {
|
|||
s.Column = keyIDMap[s.Column]
|
||||
}
|
||||
|
||||
if nil != view.Group {
|
||||
view.Group.Field = keyIDMap[view.Group.Field]
|
||||
}
|
||||
|
||||
switch view.LayoutType {
|
||||
case LayoutTypeTable:
|
||||
for _, column := range view.Table.Columns {
|
||||
|
|
|
@ -49,7 +49,8 @@ type BaseInstance struct {
|
|||
HideAttrViewName bool `json:"hideAttrViewName"` // 是否隐藏属性视图名称
|
||||
Filters []*ViewFilter `json:"filters"` // 过滤规则
|
||||
Sorts []*ViewSort `json:"sorts"` // 排序规则
|
||||
PageSize int `json:"pageSize"` // 每页项目
|
||||
Group *ViewGroup `json:"group"` // 分组规则
|
||||
PageSize int `json:"pageSize"` // 每页项目数
|
||||
}
|
||||
|
||||
func (baseInstance *BaseInstance) GetSorts() []*ViewSort {
|
||||
|
|
|
@ -1876,6 +1876,13 @@ func (tx *Transaction) doDuplicateAttrViewView(operation *Operation) (ret *TxErr
|
|||
})
|
||||
}
|
||||
|
||||
if nil != masterView.Group {
|
||||
if copyErr := copier.Copy(view.Group, masterView.Group); nil != copyErr {
|
||||
logging.LogErrorf("copy group failed: %s", copyErr)
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: avID, msg: copyErr.Error()}
|
||||
}
|
||||
}
|
||||
|
||||
view.PageSize = masterView.PageSize
|
||||
|
||||
switch masterView.LayoutType {
|
||||
|
|
|
@ -25,6 +25,7 @@ func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query
|
|||
HideAttrViewName: view.HideAttrViewName,
|
||||
Filters: view.Filters,
|
||||
Sorts: view.Sorts,
|
||||
Group: view.Group,
|
||||
},
|
||||
CoverFrom: view.Gallery.CoverFrom,
|
||||
CoverFromAssetKeyID: view.Gallery.CoverFromAssetKeyID,
|
||||
|
|
|
@ -32,6 +32,7 @@ func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query s
|
|||
HideAttrViewName: view.HideAttrViewName,
|
||||
Filters: view.Filters,
|
||||
Sorts: view.Sorts,
|
||||
Group: view.Group,
|
||||
},
|
||||
Columns: []*av.TableColumn{},
|
||||
Rows: []*av.TableRow{},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue