mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16: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
0d57661632
commit
848289ef54
1 changed files with 12 additions and 1 deletions
|
|
@ -18,6 +18,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
@ -790,6 +791,11 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {
|
||||||
// operation.BackRelationKeyID 双向关联的目标关联列 ID
|
// operation.BackRelationKeyID 双向关联的目标关联列 ID
|
||||||
// operation.Name 双向关联的目标关联列名称
|
// operation.Name 双向关联的目标关联列名称
|
||||||
|
|
||||||
|
if "" == operation.AvID || "" == operation.ID || "" == operation.KeyID {
|
||||||
|
err = errors.New("invalid operation")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
srcAv, err := av.ParseAttributeView(operation.AvID)
|
srcAv, err := av.ParseAttributeView(operation.AvID)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return
|
return
|
||||||
|
|
@ -862,10 +868,15 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {
|
||||||
|
|
||||||
if !destAdded {
|
if !destAdded {
|
||||||
if operation.IsTwoWay {
|
if operation.IsTwoWay {
|
||||||
|
name := strings.TrimSpace(operation.Name)
|
||||||
|
if "" == name {
|
||||||
|
name = destAv.Name
|
||||||
|
}
|
||||||
|
|
||||||
destAv.KeyValues = append(destAv.KeyValues, &av.KeyValues{
|
destAv.KeyValues = append(destAv.KeyValues, &av.KeyValues{
|
||||||
Key: &av.Key{
|
Key: &av.Key{
|
||||||
ID: operation.BackRelationKeyID,
|
ID: operation.BackRelationKeyID,
|
||||||
Name: operation.Name,
|
Name: name,
|
||||||
Type: av.KeyTypeRelation,
|
Type: av.KeyTypeRelation,
|
||||||
Relation: &av.Relation{AvID: operation.AvID, IsTwoWay: operation.IsTwoWay, BackKeyID: operation.KeyID},
|
Relation: &av.Relation{AvID: operation.AvID, IsTwoWay: operation.IsTwoWay, BackKeyID: operation.KeyID},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue