diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 9767722aa..19961289c 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -801,6 +801,9 @@ func updateAttributeViewColRelation(operation *Operation) (err error) { } isSameAv := srcAv.ID == destAv.ID + if isSameAv { + destAv = srcAv + } for _, keyValues := range srcAv.KeyValues { if keyValues.Key.ID == operation.KeyID { @@ -849,14 +852,23 @@ func updateAttributeViewColRelation(operation *Operation) (err error) { } if !destAdded { - destAv.KeyValues = append(destAv.KeyValues, &av.KeyValues{ - Key: &av.Key{ - ID: operation.BackRelationKeyID, - Name: operation.Name, - Type: av.KeyTypeRelation, - Relation: &av.Relation{AvID: operation.AvID, IsTwoWay: operation.IsTwoWay, BackKeyID: operation.KeyID}, - }, - }) + if operation.IsTwoWay { + destAv.KeyValues = append(destAv.KeyValues, &av.KeyValues{ + Key: &av.Key{ + ID: operation.BackRelationKeyID, + Name: operation.Name, + Type: av.KeyTypeRelation, + Relation: &av.Relation{AvID: operation.AvID, IsTwoWay: operation.IsTwoWay, BackKeyID: operation.KeyID}, + }, + }) + + for _, v := range destAv.Views { + switch v.LayoutType { + case av.LayoutTypeTable: + v.Table.Columns = append(v.Table.Columns, &av.ViewTableColumn{ID: operation.BackRelationKeyID}) + } + } + } } err = av.SaveAttributeView(srcAv) diff --git a/kernel/treenode/node.go b/kernel/treenode/node.go index 82ef223c0..7e80aa0e2 100644 --- a/kernel/treenode/node.go +++ b/kernel/treenode/node.go @@ -600,10 +600,9 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a // 组装列 for _, col := range view.Table.Columns { - key, getErr := attrView.GetKey(col.ID) - if nil != getErr { - err = getErr - return + key, _ := attrView.GetKey(col.ID) + if nil == key { + continue } ret.Columns = append(ret.Columns, &av.TableColumn{