Преглед изворни кода

Merge remote-tracking branch 'origin/dev' into dev

Vanessa пре 1 година
родитељ
комит
67af0fbe9a
2 измењених фајлова са 23 додато и 12 уклоњено
  1. 20 8
      kernel/model/attribute_view.go
  2. 3 4
      kernel/treenode/node.go

+ 20 - 8
kernel/model/attribute_view.go

@@ -801,6 +801,9 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {
 	}
 	}
 
 
 	isSameAv := srcAv.ID == destAv.ID
 	isSameAv := srcAv.ID == destAv.ID
+	if isSameAv {
+		destAv = srcAv
+	}
 
 
 	for _, keyValues := range srcAv.KeyValues {
 	for _, keyValues := range srcAv.KeyValues {
 		if keyValues.Key.ID == operation.KeyID {
 		if keyValues.Key.ID == operation.KeyID {
@@ -849,14 +852,23 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {
 	}
 	}
 
 
 	if !destAdded {
 	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)
 	err = av.SaveAttributeView(srcAv)

+ 3 - 4
kernel/treenode/node.go

@@ -600,10 +600,9 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
 
 
 	// 组装列
 	// 组装列
 	for _, col := range view.Table.Columns {
 	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{
 		ret.Columns = append(ret.Columns, &av.TableColumn{