mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-15 03:28:07 +01:00
🎨 Update av
This commit is contained in:
parent
7f9a8842f9
commit
4211248740
3 changed files with 82 additions and 2 deletions
|
|
@ -19,6 +19,7 @@ package model
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
|
|
@ -40,6 +41,36 @@ func RenderAttributeView(avID string) (ret *av.AttributeView, err error) {
|
|||
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
|
||||
return
|
||||
}
|
||||
|
||||
if 0 < len(ret.Sorts) {
|
||||
var colIndexes []int
|
||||
for _, s := range ret.Sorts {
|
||||
for i, c := range ret.Columns {
|
||||
if c.ID == s.Column {
|
||||
colIndexes = append(colIndexes, i)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(ret.Rows, func(i, j int) bool {
|
||||
less := false
|
||||
for _, index := range colIndexes {
|
||||
c := ret.Columns[index]
|
||||
if c.Type == av.ColumnTypeBlock {
|
||||
continue
|
||||
}
|
||||
|
||||
result := ret.Rows[i].Cells[index].Value.Compare(ret.Rows[j].Cells[index].Value)
|
||||
if 0 == result {
|
||||
continue
|
||||
} else if 0 > result {
|
||||
less = true
|
||||
}
|
||||
}
|
||||
return less
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue