Browse Source

feat(core): Add support for relation custom fields on Channel entity

Relates to #598
Michael Bromley 5 years ago
parent
commit
7b96b9fe77
1 changed files with 4 additions and 0 deletions
  1. 4 0
      packages/core/src/service/services/channel.service.ts

+ 4 - 0
packages/core/src/service/services/channel.service.ts

@@ -23,6 +23,7 @@ import { VendureEntity } from '../../entity/base/base.entity';
 import { Channel } from '../../entity/channel/channel.entity';
 import { ProductVariantPrice } from '../../entity/product-variant/product-variant-price.entity';
 import { Zone } from '../../entity/zone/zone.entity';
+import { CustomFieldRelationService } from '../helpers/custom-field-relation/custom-field-relation.service';
 import { patchEntity } from '../helpers/utils/patch-entity';
 import { TransactionalConnection } from '../transaction/transactional-connection';
 
@@ -36,6 +37,7 @@ export class ChannelService {
         private connection: TransactionalConnection,
         private configService: ConfigService,
         private globalSettingsService: GlobalSettingsService,
+        private customFieldRelationService: CustomFieldRelationService,
     ) {}
 
     /**
@@ -159,6 +161,7 @@ export class ChannelService {
             );
         }
         const newChannel = await this.connection.getRepository(ctx, Channel).save(channel);
+        await this.customFieldRelationService.updateRelations(ctx, Channel, input, newChannel);
         await this.updateAllChannels(ctx);
         return channel;
     }
@@ -191,6 +194,7 @@ export class ChannelService {
             );
         }
         await this.connection.getRepository(ctx, Channel).save(updatedChannel, { reload: false });
+        await this.customFieldRelationService.updateRelations(ctx, Channel, input, updatedChannel);
         await this.updateAllChannels(ctx);
         return assertFound(this.findOne(ctx, channel.id));
     }