🎨 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:35:24 +08:00
parent 0c6c80ffbd
commit 9578e55446
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 154 additions and 131 deletions

View file

@ -35,7 +35,6 @@ type Value struct {
Text *ValueText `json:"text,omitempty"`
Number *ValueNumber `json:"number,omitempty"`
Date *ValueDate `json:"date,omitempty"`
Select *ValueSelect `json:"select,omitempty"`
MSelect []*ValueSelect `json:"mSelect,omitempty"`
}
@ -78,9 +77,7 @@ func (value *Value) Compare(other *Value) int {
return 0
}
}
if nil != value.Select && nil != other.Select {
return strings.Compare(value.Select.Content, other.Select.Content)
}
if nil != value.MSelect && nil != other.MSelect {
var v1 string
for _, v := range value.MSelect {
@ -172,21 +169,12 @@ func (value *Value) CompareOperator(other *Value, operator FilterOperator) bool
}
}
if nil != value.Select && nil != other.Select {
if nil != value.MSelect && nil != other.MSelect && 0 < len(value.MSelect) && 0 < len(other.MSelect) {
switch operator {
case FilterOperatorIsEqual:
return value.Select.Content == other.Select.Content
return value.MSelect[0].Content == other.MSelect[0].Content
case FilterOperatorIsNotEqual:
return value.Select.Content != other.Select.Content
case FilterOperatorIsEmpty:
return "" == strings.TrimSpace(value.Select.Content)
case FilterOperatorIsNotEmpty:
return "" != strings.TrimSpace(value.Select.Content)
}
}
if nil != value.MSelect && nil != other.MSelect {
switch operator {
return value.MSelect[0].Content != other.MSelect[0].Content
case FilterOperatorContains:
for _, v := range value.MSelect {
if v.Content == other.MSelect[0].Content {