Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Add multi-select type column to Attribute View https://github.com/siyuan-note/siyuan/issues/8695

Daniel19a00c93f750
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 316e9603cd..7a875cf316 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -325,11 +325,9 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
colID := operation.ID
data := operation.Data.(map[string]interface{})
- var oldName, newName string
- if nil == data["newName"] {
- oldName = data["oldName"].(string)
- newName = data["newName"].(string)
- }
+ oldName := data["oldName"].(string)
+ newName := data["newName"].(string)
+ newColor := data["newColor"].(string)
var colIndex int
for i, col := range attrView.Columns {
@@ -345,6 +343,7 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
}
opt.Name = newName
+ opt.Color = newColor
break
}
break
@@ -352,23 +351,23 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
for _, row := range attrView.Rows {
for k, cell := range row.Cells {
- if colIndex != k {
+ if colIndex != k || nil == cell.Value {
continue
}
- if nil != cell.Value {
- if nil != cell.Value.Select {
- if oldName == cell.Value.Select.Content {
- cell.Value.Select.Content = newName
+ if nil != cell.Value.Select {
+ if oldName == cell.Value.Select.Content {
+ cell.Value.Select.Content = newName
+ cell.Value.Select.Color = newColor
+ break
+ }
+ } else if nil != cell.Value.MSelect {
+ for j, opt := range cell.Value.MSelect {
+ if oldName == opt.Content {
+ cell.Value.MSelect[j].Content = newName
+ cell.Value.MSelect[j].Color = newColor
break
}
- } else if nil != cell.Value.MSelect {
- for j, opt := range cell.Value.MSelect {
- if oldName == opt.Content {
- cell.Value.MSelect[j].Content = newName
- break
- }
- }
}
}
break