This commit is contained in:
Daniel 2025-06-13 10:39:04 +08:00
parent e3f08bfafd
commit 0c3f06fa3e
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 90 additions and 92 deletions

View file

@ -151,6 +151,14 @@ func (table *Table) SetItems(items []Item) {
}
}
func (table *Table) GetFields() []Field {
fields := []Field{}
for _, column := range table.Columns {
fields = append(fields, column)
}
return fields
}
func (*Table) GetType() LayoutType {
return LayoutTypeTable
}
@ -273,50 +281,5 @@ func (table *Table) Sort(attrView *AttributeView) {
}
func (table *Table) Filter(attrView *AttributeView) {
if 1 > len(table.Filters) {
return
}
var colIndexes []int
for _, f := range table.Filters {
for i, c := range table.Columns {
if c.ID == f.Column {
colIndexes = append(colIndexes, i)
break
}
}
}
rows := []*TableRow{}
attrViewCache := map[string]*AttributeView{}
attrViewCache[attrView.ID] = attrView
for _, row := range table.Rows {
pass := true
for j, index := range colIndexes {
operator := table.Filters[j].Operator
if nil == row.Cells[index].Value {
if FilterOperatorIsNotEmpty == operator {
pass = false
} else if FilterOperatorIsEmpty == operator {
pass = true
break
}
if KeyTypeText != row.Cells[index].ValueType {
pass = false
}
break
}
if !row.Cells[index].Value.Filter(table.Filters[j], attrView, row.ID, &attrViewCache) {
pass = false
break
}
}
if pass {
rows = append(rows, row)
}
}
table.Rows = rows
filter(table, attrView)
}