Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-12-23 11:25:40 +08:00
commit a41eac8659
2 changed files with 27 additions and 11 deletions

View file

@ -591,19 +591,31 @@ func (value *Value) CompareOperator(other *Value, operator FilterOperator) bool
if nil != value.Relation && nil != other.Relation {
switch operator {
case FilterOperatorContains:
if "" == strings.TrimSpace(other.Relation.Content) {
return true
contains := false
for _, c := range value.Relation.Contents {
for _, c1 := range other.Relation.Contents {
if c == c1 {
contains = true
break
}
}
}
return strings.Contains(value.Relation.Content, other.Relation.Content)
return contains
case FilterOperatorDoesNotContain:
if "" == strings.TrimSpace(other.Relation.Content) {
return true
contains := false
for _, c := range value.Relation.Contents {
for _, c2 := range other.Relation.Contents {
if c == c2 {
contains = true
break
}
}
}
return !strings.Contains(value.Relation.Content, other.Relation.Content)
return !contains
case FilterOperatorIsEmpty:
return "" == strings.TrimSpace(value.Relation.Content)
return 0 == len(value.Relation.Contents) || 1 == len(value.Relation.Contents) && "" == value.Relation.Contents[0]
case FilterOperatorIsNotEmpty:
return "" != strings.TrimSpace(value.Relation.Content)
return 0 != len(value.Relation.Contents) && !(1 == len(value.Relation.Contents) && "" == value.Relation.Contents[0])
}
}

View file

@ -142,10 +142,14 @@ func (value *Value) String() string {
}
return ""
case KeyTypeRelation:
if nil == value.Relation {
if 1 > len(value.Relation.Contents) {
return ""
}
return value.Relation.Content
var ret []string
for _, v := range value.Relation.Contents {
ret = append(ret, v)
}
return strings.Join(ret, " ")
case KeyTypeRollup:
if nil == value.Rollup {
return ""
@ -463,7 +467,7 @@ type ValueCheckbox struct {
}
type ValueRelation struct {
Content string `json:"content"`
Contents []string `json:"contents"`
BlockIDs []string `json:"blockIDs"`
}