@@ -57,6 +57,7 @@ export class LocationRepository extends DtoRepository(Location) {
57
57
createRelationships ( Location , 'out' , {
58
58
fundingAccount : [ 'FundingAccount' , input . fundingAccountId ] ,
59
59
defaultFieldRegion : [ 'FieldRegion' , input . defaultFieldRegionId ] ,
60
+ defaultMarketingRegion : [ 'Location' , input . defaultMarketingRegionId ] ,
60
61
} ) ,
61
62
)
62
63
. return < { id : ID } > ( 'node.id as id' ) ;
@@ -74,6 +75,7 @@ export class LocationRepository extends DtoRepository(Location) {
74
75
id,
75
76
fundingAccountId,
76
77
defaultFieldRegionId,
78
+ defaultMarketingRegionId,
77
79
mapImage,
78
80
...simpleChanges
79
81
} = changes ;
@@ -97,6 +99,15 @@ export class LocationRepository extends DtoRepository(Location) {
97
99
defaultFieldRegionId ,
98
100
) ;
99
101
}
102
+
103
+ if ( defaultMarketingRegionId !== undefined ) {
104
+ await this . updateRelation (
105
+ 'defaultMarketingRegion' ,
106
+ 'Location' ,
107
+ id ,
108
+ defaultMarketingRegionId ,
109
+ ) ;
110
+ }
100
111
}
101
112
102
113
protected hydrate ( ) {
@@ -113,10 +124,16 @@ export class LocationRepository extends DtoRepository(Location) {
113
124
relation ( 'out' , '' , 'defaultFieldRegion' , ACTIVE ) ,
114
125
node ( 'defaultFieldRegion' , 'FieldRegion' ) ,
115
126
] )
127
+ . optionalMatch ( [
128
+ node ( 'node' ) ,
129
+ relation ( 'out' , '' , 'defaultMarketingRegion' , ACTIVE ) ,
130
+ node ( 'defaultMarketingRegion' , 'Location' ) ,
131
+ ] )
116
132
. return < { dto : UnsecuredDto < Location > } > (
117
133
merge ( 'props' , {
118
134
fundingAccount : 'fundingAccount.id' ,
119
135
defaultFieldRegion : 'defaultFieldRegion.id' ,
136
+ defaultMarketingRegion : 'defaultMarketingRegion.id' ,
120
137
} ) . as ( 'dto' ) ,
121
138
) ;
122
139
}
0 commit comments