mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Update av
This commit is contained in:
parent
4211248740
commit
05d4b7726d
3 changed files with 113 additions and 12 deletions
|
|
@ -42,6 +42,46 @@ func RenderAttributeView(avID string) (ret *av.AttributeView, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
filterRows(ret)
|
||||
sortRows(ret)
|
||||
return
|
||||
}
|
||||
|
||||
func filterRows(ret *av.AttributeView) {
|
||||
if 0 < len(ret.Filters) {
|
||||
var colIndexes []int
|
||||
for _, f := range ret.Filters {
|
||||
for i, c := range ret.Columns {
|
||||
if c.ID == f.Column {
|
||||
colIndexes = append(colIndexes, i)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var rows []*av.Row
|
||||
for _, row := range ret.Rows {
|
||||
pass := true
|
||||
for j, index := range colIndexes {
|
||||
c := ret.Columns[index]
|
||||
if c.Type == av.ColumnTypeBlock {
|
||||
continue
|
||||
}
|
||||
|
||||
if !row.Cells[index].Value.CompareOperator(ret.Filters[j].Value, ret.Filters[j].Operator) {
|
||||
pass = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if pass {
|
||||
rows = append(rows, row)
|
||||
}
|
||||
}
|
||||
ret.Rows = rows
|
||||
}
|
||||
}
|
||||
|
||||
func sortRows(ret *av.AttributeView) {
|
||||
if 0 < len(ret.Sorts) {
|
||||
var colIndexes []int
|
||||
for _, s := range ret.Sorts {
|
||||
|
|
@ -71,7 +111,6 @@ func RenderAttributeView(avID string) (ret *av.AttributeView, err error) {
|
|||
return less
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue