mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-02 06:48:49 +01:00
🎨 Add Relation column to database table view https://github.com/siyuan-note/siyuan/issues/9888
This commit is contained in:
parent
d2a32d2903
commit
ddc07027a7
1 changed files with 22 additions and 2 deletions
|
|
@ -203,9 +203,29 @@ func (value *Value) Compare(other *Value) int {
|
|||
return 0
|
||||
}
|
||||
case KeyTypeRelation:
|
||||
// TODO: relation compare
|
||||
if nil != value.Relation && nil != other.Relation {
|
||||
vContent := strings.TrimSpace(strings.Join(value.Relation.Contents, " "))
|
||||
oContent := strings.TrimSpace(strings.Join(other.Relation.Contents, " "))
|
||||
return strings.Compare(vContent, oContent)
|
||||
}
|
||||
case KeyTypeRollup:
|
||||
// TODO: rollup compare
|
||||
if nil != value.Rollup && nil != other.Rollup {
|
||||
vContent := strings.TrimSpace(strings.Join(value.Relation.Contents, " "))
|
||||
oContent := strings.TrimSpace(strings.Join(other.Relation.Contents, " "))
|
||||
if util.IsNumeric(vContent) && util.IsNumeric(oContent) {
|
||||
v1, _ := strconv.ParseFloat(vContent, 64)
|
||||
v2, _ := strconv.ParseFloat(oContent, 64)
|
||||
if v1 > v2 {
|
||||
return 1
|
||||
}
|
||||
|
||||
if v1 < v2 {
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
return strings.Compare(vContent, oContent)
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue