mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🐛 In some cases, the primary key sorting of the database panel fails https://github.com/siyuan-note/siyuan/issues/11621
This commit is contained in:
parent
06993bddd5
commit
02fe7b966c
1 changed files with 25 additions and 18 deletions
|
|
@ -649,6 +649,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 字段排序
|
// 字段排序
|
||||||
|
refreshAttrViewKeyIDs(attrView)
|
||||||
sorts := map[string]int{}
|
sorts := map[string]int{}
|
||||||
for i, k := range attrView.KeyIDs {
|
for i, k := range attrView.KeyIDs {
|
||||||
sorts[k] = i
|
sorts[k] = i
|
||||||
|
|
@ -2449,24 +2450,7 @@ func SortAttributeViewKey(avID, keyID, previousKeyID string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
existKeyIDs := map[string]bool{}
|
refreshAttrViewKeyIDs(attrView)
|
||||||
for _, keyValues := range attrView.KeyValues {
|
|
||||||
existKeyIDs[keyValues.Key.ID] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, _ := range existKeyIDs {
|
|
||||||
if !gulu.Str.Contains(k, attrView.KeyIDs) {
|
|
||||||
attrView.KeyIDs = append(attrView.KeyIDs, k)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var tmp []string
|
|
||||||
for _, k := range attrView.KeyIDs {
|
|
||||||
if ok := existKeyIDs[k]; ok {
|
|
||||||
tmp = append(tmp, k)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
attrView.KeyIDs = tmp
|
|
||||||
|
|
||||||
var currentKeyID string
|
var currentKeyID string
|
||||||
var idx, previousIndex int
|
var idx, previousIndex int
|
||||||
|
|
@ -2495,6 +2479,29 @@ func SortAttributeViewKey(avID, keyID, previousKeyID string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func refreshAttrViewKeyIDs(attrView *av.AttributeView) {
|
||||||
|
// 订正 keyIDs 数据
|
||||||
|
|
||||||
|
existKeyIDs := map[string]bool{}
|
||||||
|
for _, keyValues := range attrView.KeyValues {
|
||||||
|
existKeyIDs[keyValues.Key.ID] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, _ := range existKeyIDs {
|
||||||
|
if !gulu.Str.Contains(k, attrView.KeyIDs) {
|
||||||
|
attrView.KeyIDs = append(attrView.KeyIDs, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var tmp []string
|
||||||
|
for _, k := range attrView.KeyIDs {
|
||||||
|
if ok := existKeyIDs[k]; ok {
|
||||||
|
tmp = append(tmp, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
attrView.KeyIDs = tmp
|
||||||
|
}
|
||||||
|
|
||||||
func (tx *Transaction) doAddAttrViewColumn(operation *Operation) (ret *TxErr) {
|
func (tx *Transaction) doAddAttrViewColumn(operation *Operation) (ret *TxErr) {
|
||||||
var icon string
|
var icon string
|
||||||
if nil != operation.Data {
|
if nil != operation.Data {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue