mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Improve database field sorting Fix https://github.com/siyuan-note/siyuan/issues/11038
This commit is contained in:
parent
483ae3b671
commit
a049eeec3e
2 changed files with 21 additions and 11 deletions
|
|
@ -119,13 +119,19 @@ func (value *Value) Compare(other *Value, attrView *AttributeView) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
case KeyTypeSelect, KeyTypeMSelect:
|
case KeyTypeSelect, KeyTypeMSelect:
|
||||||
if 0 < len(value.MSelect) && 0 < len(other.MSelect) {
|
if nil != value.MSelect && nil != other.MSelect {
|
||||||
v1 := value.MSelect[0].Content
|
var v1 string
|
||||||
v2 := other.MSelect[0].Content
|
for _, v := range value.MSelect {
|
||||||
if v1 == v2 {
|
v1 += v.Content
|
||||||
return 0
|
break
|
||||||
|
}
|
||||||
|
var v2 string
|
||||||
|
for _, v := range other.MSelect {
|
||||||
|
v2 += v.Content
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 按设置的选项顺序排序
|
||||||
key, _ := attrView.GetKey(value.KeyID)
|
key, _ := attrView.GetKey(value.KeyID)
|
||||||
if nil != key {
|
if nil != key {
|
||||||
optionSort := map[string]int{}
|
optionSort := map[string]int{}
|
||||||
|
|
|
||||||
|
|
@ -213,13 +213,17 @@ func (table *Table) SortRows(attrView *AttributeView) {
|
||||||
sorted := true
|
sorted := true
|
||||||
for _, colIndexSort := range colIndexSorts {
|
for _, colIndexSort := range colIndexSorts {
|
||||||
val1 := editedRows[i].Cells[colIndexSort.Index].Value
|
val1 := editedRows[i].Cells[colIndexSort.Index].Value
|
||||||
if nil == val1 {
|
|
||||||
return colIndexSort.Order == SortOrderAsc
|
|
||||||
}
|
|
||||||
|
|
||||||
val2 := editedRows[j].Cells[colIndexSort.Index].Value
|
val2 := editedRows[j].Cells[colIndexSort.Index].Value
|
||||||
if nil == val2 {
|
if nil == val1 || val1.IsEmpty() {
|
||||||
return colIndexSort.Order != SortOrderAsc
|
if nil != val2 && !val2.IsEmpty() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
sorted = false
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
if nil == val2 || val2.IsEmpty() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result := val1.Compare(val2, attrView)
|
result := val1.Compare(val2, attrView)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue