|
@@ -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)
|