mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
🎨 Attribute View number column format https://github.com/siyuan-note/siyuan/issues/8764
This commit is contained in:
parent
760598d943
commit
9a5e9f1a14
2 changed files with 55 additions and 4 deletions
|
|
@ -149,6 +149,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
|||
Sorts: view.Table.Sorts,
|
||||
}
|
||||
|
||||
// 组装列
|
||||
for _, col := range view.Table.Columns {
|
||||
key, getErr := attrView.GetKey(col.ID)
|
||||
if nil != getErr {
|
||||
|
|
@ -169,6 +170,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
|||
})
|
||||
}
|
||||
|
||||
// 生成行
|
||||
rows := map[string][]*av.Value{}
|
||||
for _, keyValues := range attrView.KeyValues {
|
||||
for _, val := range keyValues.Values {
|
||||
|
|
@ -176,6 +178,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
|||
}
|
||||
}
|
||||
|
||||
// 过滤掉不存在的行
|
||||
notFound := []string{}
|
||||
for blockID, _ := range rows {
|
||||
if treenode.GetBlockTree(blockID) == nil {
|
||||
|
|
@ -186,6 +189,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
|||
delete(rows, blockID)
|
||||
}
|
||||
|
||||
// 生成行单元格
|
||||
for rowID, row := range rows {
|
||||
var tableRow av.TableRow
|
||||
for _, col := range ret.Columns {
|
||||
|
|
@ -207,11 +211,17 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
|
|||
}
|
||||
}
|
||||
tableRow.ID = rowID
|
||||
|
||||
if av.KeyTypeNumber == tableCell.ValueType {
|
||||
tableCell.Value.Number.FormatNumber()
|
||||
}
|
||||
|
||||
tableRow.Cells = append(tableRow.Cells, tableCell)
|
||||
}
|
||||
ret.Rows = append(ret.Rows, &tableRow)
|
||||
}
|
||||
|
||||
// 自定义排序
|
||||
sortRowIDs := map[string]int{}
|
||||
if 0 < len(view.Table.RowIDs) {
|
||||
for i, rowID := range view.Table.RowIDs {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue