🎨 Database select field filters follow option editing changes https://github.com/siyuan-note/siyuan/issues/10881

This commit is contained in:
Daniel 2024-04-06 10:11:23 +08:00
parent 1d2516afb9
commit 435a53cb49
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017

View File

@ -3251,6 +3251,7 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
}
}
// 如果存在选项对应的值,需要更新值中的选项
for _, keyValues := range attrView.KeyValues {
if keyValues.Key.ID != operation.ID {
continue
@ -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
}