mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-06 12:50:16 +01:00
🎨 Add Relation column to database table view https://github.com/siyuan-note/siyuan/issues/9888
This commit is contained in:
parent
f3956f10dc
commit
c1bec499b4
1 changed files with 14 additions and 17 deletions
|
|
@ -1906,23 +1906,20 @@ func removeAttributeViewColumn(operation *Operation) (err error) {
|
|||
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 i, keyValues := range destAv.KeyValues {
|
||||
if keyValues.Key.ID == removedKey.Relation.BackKeyID {
|
||||
destAv.KeyValues = append(destAv.KeyValues[:i], destAv.KeyValues[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
|
||||
}
|
||||
for _, view := range destAv.Views {
|
||||
switch view.LayoutType {
|
||||
case av.LayoutTypeTable:
|
||||
for i, column := range view.Table.Columns {
|
||||
if column.ID == removedKey.ID {
|
||||
view.Table.Columns = append(view.Table.Columns[:i], view.Table.Columns[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2087,12 +2084,12 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,
|
|||
// 将游离行绑定到新建的块上
|
||||
bindBlockAv(tx, avID, rowID)
|
||||
}
|
||||
} else { // 之前绑定了块
|
||||
} else { // 之前绑定了块
|
||||
if isUpdatingBlockKey { // 正在更新主键
|
||||
if val.IsDetached { // 现在是游离行
|
||||
// 将绑定的块从属性视图中移除
|
||||
unbindBlockAv(tx, avID, rowID)
|
||||
} else { // 现在绑定了块
|
||||
} else { // 现在绑定了块
|
||||
if oldBoundBlockID != val.BlockID { // 之前绑定的块和现在绑定的块不一样
|
||||
// 换绑块
|
||||
unbindBlockAv(tx, avID, oldBoundBlockID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue