mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 10:19:54 +08:00
🎨 Add multi-select type column to Attribute View https://github.com/siyuan-note/siyuan/issues/8695
This commit is contained in:
parent
96e7044baf
commit
2f84aaa4c7
@ -329,6 +329,8 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
|
|||||||
newName := data["newName"].(string)
|
newName := data["newName"].(string)
|
||||||
newColor := data["newColor"].(string)
|
newColor := data["newColor"].(string)
|
||||||
|
|
||||||
|
// TODO 如果 newName 已经存在
|
||||||
|
|
||||||
var colIndex int
|
var colIndex int
|
||||||
for i, col := range attrView.Columns {
|
for i, col := range attrView.Columns {
|
||||||
if col.ID != colID {
|
if col.ID != colID {
|
||||||
@ -336,15 +338,23 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
colIndex = i
|
colIndex = i
|
||||||
|
existOpt := false
|
||||||
for _, opt := range col.Options {
|
for _, opt := range col.Options {
|
||||||
if opt.Name != oldName {
|
if opt.Name == newName {
|
||||||
continue
|
existOpt = true
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if !existOpt {
|
||||||
|
for _, opt := range col.Options {
|
||||||
|
if opt.Name != oldName {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
opt.Name = newName
|
opt.Name = newName
|
||||||
opt.Color = newColor
|
opt.Color = newColor
|
||||||
break
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -362,13 +372,22 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if nil != cell.Value.MSelect {
|
} else if nil != cell.Value.MSelect {
|
||||||
for j, opt := range cell.Value.MSelect {
|
existInMSelect := false
|
||||||
if oldName == opt.Content {
|
for _, opt := range cell.Value.MSelect {
|
||||||
cell.Value.MSelect[j].Content = newName
|
if opt.Content == newName {
|
||||||
cell.Value.MSelect[j].Color = newColor
|
existInMSelect = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !existInMSelect {
|
||||||
|
for j, opt := range cell.Value.MSelect {
|
||||||
|
if oldName == opt.Content {
|
||||||
|
cell.Value.MSelect[j].Content = newName
|
||||||
|
cell.Value.MSelect[j].Color = newColor
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user