mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Database table view supports paged loading https://github.com/siyuan-note/siyuan/issues/9424
This commit is contained in:
parent
535f72afdb
commit
79960b4da2
3 changed files with 45 additions and 11 deletions
|
|
@ -32,6 +32,7 @@ type LayoutTable struct {
|
|||
RowIDs []string `json:"rowIds"` // 行 ID,用于自定义排序
|
||||
Filters []*ViewFilter `json:"filters"` // 过滤规则
|
||||
Sorts []*ViewSort `json:"sorts"` // 排序规则
|
||||
PageSize int `json:"pageSize"` // 每页行数
|
||||
}
|
||||
|
||||
type ViewTableColumn struct {
|
||||
|
|
@ -578,6 +579,7 @@ type Table struct {
|
|||
Sorts []*ViewSort `json:"sorts"` // 排序规则
|
||||
Columns []*TableColumn `json:"columns"` // 表格列
|
||||
Rows []*TableRow `json:"rows"` // 表格行
|
||||
RowCount int `json:"rowCount"` // 表格总行数
|
||||
}
|
||||
|
||||
type TableColumn struct {
|
||||
|
|
|
|||
|
|
@ -622,6 +622,8 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View, page, p
|
|||
return iv < jv
|
||||
})
|
||||
|
||||
// 分页
|
||||
ret.RowCount = len(ret.Rows)
|
||||
if 0 < pageSize {
|
||||
start := (page - 1) * pageSize
|
||||
end := start + pageSize
|
||||
|
|
@ -959,6 +961,34 @@ func setAttributeViewSorts(operation *Operation) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewPageSize(operation *Operation) (ret *TxErr) {
|
||||
err := setAttributeViewPageSize(operation)
|
||||
if nil != err {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID, msg: err.Error()}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func setAttributeViewPageSize(operation *Operation) (err error) {
|
||||
attrView, err := av.ParseAttributeView(operation.AvID)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
view, err := attrView.GetCurrentView()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
view.Table.PageSize = int(operation.Data.(float64))
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doSetAttrViewColCalc(operation *Operation) (ret *TxErr) {
|
||||
err := setAttributeViewColumnCalc(operation)
|
||||
if nil != err {
|
||||
|
|
|
|||
|
|
@ -204,6 +204,8 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
ret = tx.doSetAttrViewFilters(op)
|
||||
case "setAttrViewSorts":
|
||||
ret = tx.doSetAttrViewSorts(op)
|
||||
case "setAttrViewPageSize":
|
||||
ret = tx.doSetAttrViewPageSize(op)
|
||||
case "setAttrViewColWidth":
|
||||
ret = tx.doSetAttrViewColumnWidth(op)
|
||||
case "setAttrViewColWrap":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue