mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
🎨 Add Relation column to database table view https://github.com/siyuan-note/siyuan/issues/9888
This commit is contained in:
parent
504d3f6155
commit
f3956f10dc
1 changed files with 34 additions and 2 deletions
|
|
@ -1893,13 +1893,45 @@ func removeAttributeViewColumn(operation *Operation) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var removedKey *av.Key
|
||||||
for i, keyValues := range attrView.KeyValues {
|
for i, keyValues := range attrView.KeyValues {
|
||||||
if keyValues.Key.ID == operation.ID {
|
if keyValues.Key.ID == operation.ID {
|
||||||
attrView.KeyValues = append(attrView.KeyValues[:i], attrView.KeyValues[i+1:]...)
|
attrView.KeyValues = append(attrView.KeyValues[:i], attrView.KeyValues[i+1:]...)
|
||||||
|
removedKey = keyValues.Key
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除双向关联的目标列
|
||||||
|
if nil != removedKey && nil != removedKey.Relation && removedKey.Relation.IsTwoWay {
|
||||||
|
destAv, _ := av.ParseAttributeView(removedKey.Relation.AvID)
|
||||||
|
if nil != destAv {
|
||||||
|
destKeyValues, _ := destAv.GetKeyValues(removedKey.Relation.BackKeyID)
|
||||||
|
if nil != destKeyValues {
|
||||||
|
for i, value := range destKeyValues.Values {
|
||||||
|
if value.KeyID == removedKey.Relation.BackKeyID {
|
||||||
|
destKeyValues.Values = append(destKeyValues.Values[:i], destKeyValues.Values[i+1:]...)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, view := range destAv.Views {
|
||||||
|
switch view.LayoutType {
|
||||||
|
case av.LayoutTypeTable:
|
||||||
|
for i, column := range view.Table.Columns {
|
||||||
|
if column.ID == operation.ID {
|
||||||
|
view.Table.Columns = append(view.Table.Columns[:i], view.Table.Columns[i+1:]...)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": destAv.ID})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, view := range attrView.Views {
|
for _, view := range attrView.Views {
|
||||||
switch view.LayoutType {
|
switch view.LayoutType {
|
||||||
case av.LayoutTypeTable:
|
case av.LayoutTypeTable:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue