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

This commit is contained in:
Daniel 2023-07-10 11:09:44 +08:00
parent 64c4bec75f
commit 19a00c93f7
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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