Browse Source

fix(admin-ui): Fix role editor Channel value display

oneyed 5 years ago
parent
commit
c258975c15

+ 1 - 0
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)"
 >

+ 5 - 1
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;
+    }
 }

+ 1 - 1
packages/admin-ui/src/lib/settings/src/components/role-detail/role-detail.component.ts

@@ -123,7 +123,7 @@ export class RoleDetailComponent extends BaseDetailComponent<Role> 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