Skip to content

Commit

Permalink
🎨 Attribute Panel - Database sort attributes by view column order #9319
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 30, 2023
1 parent 1063f50 commit ca855c1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
}
}

// Attribute Panel - Database sort attributes by view column order https://github.com/siyuan-note/siyuan/issues/9319
view, _ := attrView.GetView()
if nil != view {
sorts := map[string]int{}
for i, col := range view.Table.Columns {
sorts[col.ID] = i
}

sort.Slice(keyValues, func(i, j int) bool {
return sorts[keyValues[i].Key.ID] < sorts[keyValues[j].Key.ID]
})
}

ret = append(ret, &BlockAttributeViewKeys{
AvID: avID,
AvName: attrView.Name,
Expand Down

0 comments on commit ca855c1

Please sign in to comment.