Skip to content

Commit

Permalink
🎨 Database select field filters follow option editing changes #10881
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Apr 6, 2024
1 parent 1d2516a commit 435a53c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions kernel/model/attribute_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -3251,6 +3251,7 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
}
}

// 如果存在选项对应的值,需要更新值中的选项
for _, keyValues := range attrView.KeyValues {
if keyValues.Key.ID != operation.ID {
continue
Expand All @@ -3272,6 +3273,30 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
break
}

// 如果存在选项对应的过滤器,需要更新过滤器中设置的选项值
// Database select field filters follow option editing changes https://github.com/siyuan-note/siyuan/issues/10881
for _, view := range attrView.Views {
switch view.LayoutType {
case av.LayoutTypeTable:
table := view.Table
for _, filter := range table.Filters {
if filter.Column != key.ID {
continue
}

if nil != filter.Value && (av.KeyTypeSelect == filter.Value.Type || av.KeyTypeMSelect == filter.Value.Type) {
for i, opt := range filter.Value.MSelect {
if oldName == opt.Content {
filter.Value.MSelect[i].Content = newName
filter.Value.MSelect[i].Color = newColor
break
}
}
}
}
}
}

err = av.SaveAttributeView(attrView)
return
}
Expand Down

0 comments on commit 435a53c

Please sign in to comment.