mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
🎨 Improve database table view select filtering https://github.com/siyuan-note/siyuan/issues/10193
This commit is contained in:
parent
0807e30762
commit
7476c3e386
1 changed files with 37 additions and 23 deletions
|
|
@ -452,30 +452,44 @@ func (value *Value) compareOperator(other *Value, operator FilterOperator, attrV
|
|||
}
|
||||
}
|
||||
|
||||
if nil != value.MSelect && nil != other.MSelect {
|
||||
if nil != value.MSelect {
|
||||
if nil != other.MSelect {
|
||||
switch operator {
|
||||
case FilterOperatorIsEqual, FilterOperatorContains:
|
||||
contains := false
|
||||
for _, v := range value.MSelect {
|
||||
for _, v2 := range other.MSelect {
|
||||
if v.Content == v2.Content {
|
||||
contains = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return contains
|
||||
case FilterOperatorIsNotEqual, FilterOperatorDoesNotContain:
|
||||
contains := false
|
||||
for _, v := range value.MSelect {
|
||||
for _, v2 := range other.MSelect {
|
||||
if v.Content == v2.Content {
|
||||
contains = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return !contains
|
||||
case FilterOperatorIsEmpty:
|
||||
return 0 == len(value.MSelect) || 1 == len(value.MSelect) && "" == value.MSelect[0].Content
|
||||
case FilterOperatorIsNotEmpty:
|
||||
return 0 != len(value.MSelect) && !(1 == len(value.MSelect) && "" == value.MSelect[0].Content)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 没有设置比较值
|
||||
|
||||
switch operator {
|
||||
case FilterOperatorIsEqual, FilterOperatorContains:
|
||||
contains := false
|
||||
for _, v := range value.MSelect {
|
||||
for _, v2 := range other.MSelect {
|
||||
if v.Content == v2.Content {
|
||||
contains = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return contains
|
||||
case FilterOperatorIsNotEqual, FilterOperatorDoesNotContain:
|
||||
contains := false
|
||||
for _, v := range value.MSelect {
|
||||
for _, v2 := range other.MSelect {
|
||||
if v.Content == v2.Content {
|
||||
contains = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return !contains
|
||||
case FilterOperatorIsEqual, FilterOperatorIsNotEqual, FilterOperatorContains, FilterOperatorDoesNotContain:
|
||||
return true
|
||||
case FilterOperatorIsEmpty:
|
||||
return 0 == len(value.MSelect) || 1 == len(value.MSelect) && "" == value.MSelect[0].Content
|
||||
case FilterOperatorIsNotEmpty:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue