From c258975c15ae3c555a85693631295d7a5cc696d4 Mon Sep 17 00:00:00 2001 From: oneyed Date: Mon, 18 Jan 2021 10:00:40 +0100 Subject: [PATCH] fix(admin-ui): Fix role editor Channel value display --- .../channel-assignment-control.component.html | 1 + .../channel-assignment-control.component.ts | 6 +++++- .../src/components/role-detail/role-detail.component.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/admin-ui/src/lib/core/src/shared/components/channel-assignment-control/channel-assignment-control.component.html b/packages/admin-ui/src/lib/core/src/shared/components/channel-assignment-control/channel-assignment-control.component.html index 342ac8b648..0de7266b47 100644 --- a/packages/admin-ui/src/lib/core/src/shared/components/channel-assignment-control/channel-assignment-control.component.html +++ b/packages/admin-ui/src/lib/core/src/shared/components/channel-assignment-control/channel-assignment-control.component.html @@ -6,6 +6,7 @@ [clearable]="false" [searchable]="false" [disabled]="disabled" + [compareWith]="compareFn" (focus)="focussed()" (change)="valueChanged($event)" > diff --git a/packages/admin-ui/src/lib/core/src/shared/components/channel-assignment-control/channel-assignment-control.component.ts b/packages/admin-ui/src/lib/core/src/shared/components/channel-assignment-control/channel-assignment-control.component.ts index f56b13fe07..a1bfeecd43 100644 --- a/packages/admin-ui/src/lib/core/src/shared/components/channel-assignment-control/channel-assignment-control.component.ts +++ b/packages/admin-ui/src/lib/core/src/shared/components/channel-assignment-control/channel-assignment-control.component.ts @@ -4,7 +4,7 @@ import { DEFAULT_CHANNEL_CODE } from '@vendure/common/lib/shared-constants'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { CurrentUserChannel } from '../../../common/generated-types'; +import { Channel, CurrentUserChannel } from '../../../common/generated-types'; import { DataService } from '../../../data/providers/data.service'; @Component({ @@ -80,4 +80,8 @@ export class ChannelAssignmentControlComponent implements OnInit, ControlValueAc this.onChange([value ? value.id : undefined]); } } + + compareFn(c1: Channel, c2: Channel): boolean { + return c1 && c2 ? c1.id === c2.id : c1 === c2; + } } diff --git a/packages/admin-ui/src/lib/settings/src/components/role-detail/role-detail.component.ts b/packages/admin-ui/src/lib/settings/src/components/role-detail/role-detail.component.ts index 8d9d48f779..c83dce27d3 100644 --- a/packages/admin-ui/src/lib/settings/src/components/role-detail/role-detail.component.ts +++ b/packages/admin-ui/src/lib/settings/src/components/role-detail/role-detail.component.ts @@ -123,7 +123,7 @@ export class RoleDetailComponent extends BaseDetailComponent implements On this.detailForm.patchValue({ description: role.description, code: role.code, - channelIds: role.channels.map(c => c.id), + channelIds: role.channels, permissions: role.permissions, }); // This was required to get the channel selector component to