🎨 Add multi-select type column to Attribute View https://github.com/siyuan-note/siyuan/issues/8695

This commit is contained in:
Daniel 2023-07-10 23:42:06 +08:00
parent 9578e55446
commit ec566692c8
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -186,7 +186,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
case CalcOperatorCountValues: case CalcOperatorCountValues:
countValues := 0 countValues := 0
for _, row := range av.Rows { 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++ countValues++
} }
} }
@ -195,8 +195,8 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
countUniqueValues := 0 countUniqueValues := 0
uniqueValues := map[string]bool{} uniqueValues := map[string]bool{}
for _, row := range av.Rows { 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 {
uniqueValues[row.Cells[colIndex].Value.Select.Content] = true uniqueValues[row.Cells[colIndex].Value.MSelect[0].Content] = true
countUniqueValues++ countUniqueValues++
} }
} }
@ -204,7 +204,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
case CalcOperatorCountEmpty: case CalcOperatorCountEmpty:
countEmpty := 0 countEmpty := 0
for _, row := range av.Rows { 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++ countEmpty++
} }
} }
@ -212,7 +212,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
case CalcOperatorCountNotEmpty: case CalcOperatorCountNotEmpty:
countNotEmpty := 0 countNotEmpty := 0
for _, row := range av.Rows { 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++ countNotEmpty++
} }
} }
@ -220,7 +220,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
case CalcOperatorPercentEmpty: case CalcOperatorPercentEmpty:
countEmpty := 0 countEmpty := 0
for _, row := range av.Rows { 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++ countEmpty++
} }
} }
@ -228,7 +228,7 @@ func (av *AttributeView) calcColSelect(col *Column, colIndex int) {
case CalcOperatorPercentNotEmpty: case CalcOperatorPercentNotEmpty:
countNotEmpty := 0 countNotEmpty := 0
for _, row := range av.Rows { 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++ countNotEmpty++
} }
} }