From ec566692c84a570e196b0915a93c1cea7b9e6e56 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 10 Jul 2023 23:42:06 +0800 Subject: [PATCH] :art: Add multi-select type column to Attribute View https://github.com/siyuan-note/siyuan/issues/8695 --- kernel/av/column.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/av/column.go b/kernel/av/column.go index f02a52f60..46bf529dd 100644 --- a/kernel/av/column.go +++ b/kernel/av/column.go @@ -186,7 +186,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) { case CalcOperatorCountValues: countValues := 0 for _, row := range av.Rows { - if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Select && "" != row.Cells[colIndex].Value.Select.Content { + if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.MSelect && 0 < len(row.Cells[colIndex].Value.MSelect) && nil != row.Cells[colIndex].Value.MSelect[0] && "" != row.Cells[colIndex].Value.MSelect[0].Content { countValues++ } } @@ -195,8 +195,8 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) { countUniqueValues := 0 uniqueValues := map[string]bool{} for _, row := range av.Rows { - if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Select && "" != row.Cells[colIndex].Value.Select.Content { - uniqueValues[row.Cells[colIndex].Value.Select.Content] = true + if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.MSelect && 0 < len(row.Cells[colIndex].Value.MSelect) && nil != row.Cells[colIndex].Value.MSelect[0] && "" != row.Cells[colIndex].Value.MSelect[0].Content { + uniqueValues[row.Cells[colIndex].Value.MSelect[0].Content] = true countUniqueValues++ } } @@ -204,7 +204,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) { case CalcOperatorCountEmpty: countEmpty := 0 for _, row := range av.Rows { - if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.Select || "" == row.Cells[colIndex].Value.Select.Content { + if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.MSelect || 1 > len(row.Cells[colIndex].Value.MSelect) || nil == row.Cells[colIndex].Value.MSelect[0] || "" == row.Cells[colIndex].Value.MSelect[0].Content { countEmpty++ } } @@ -212,7 +212,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) { case CalcOperatorCountNotEmpty: countNotEmpty := 0 for _, row := range av.Rows { - if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Select && "" != row.Cells[colIndex].Value.Select.Content { + if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.MSelect && 0 < len(row.Cells[colIndex].Value.MSelect) && nil != row.Cells[colIndex].Value.MSelect[0] && "" != row.Cells[colIndex].Value.MSelect[0].Content { countNotEmpty++ } } @@ -220,7 +220,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) { case CalcOperatorPercentEmpty: countEmpty := 0 for _, row := range av.Rows { - if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.Select || "" == row.Cells[colIndex].Value.Select.Content { + if nil == row.Cells[colIndex] || nil == row.Cells[colIndex].Value || nil == row.Cells[colIndex].Value.MSelect || 1 > len(row.Cells[colIndex].Value.MSelect) || nil == row.Cells[colIndex].Value.MSelect[0] || "" == row.Cells[colIndex].Value.MSelect[0].Content { countEmpty++ } } @@ -228,7 +228,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) { case CalcOperatorPercentNotEmpty: countNotEmpty := 0 for _, row := range av.Rows { - if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.Select && "" != row.Cells[colIndex].Value.Select.Content { + if nil != row.Cells[colIndex] && nil != row.Cells[colIndex].Value && nil != row.Cells[colIndex].Value.MSelect && 0 < len(row.Cells[colIndex].Value.MSelect) && nil != row.Cells[colIndex].Value.MSelect[0] && "" != row.Cells[colIndex].Value.MSelect[0].Content { countNotEmpty++ } }