Browse Source

fix(admin-ui): Correctly render channels in Role detail view

Michael Bromley 5 years ago
parent
commit
cfb3c03419

+ 3 - 3
packages/admin-ui/src/lib/core/src/shared/components/channel-assignment-control/channel-assignment-control.component.ts

@@ -11,7 +11,7 @@ import { DataService } from '../../../data/providers/data.service';
     selector: 'vdr-channel-assignment-control',
     templateUrl: './channel-assignment-control.component.html',
     styleUrls: ['./channel-assignment-control.component.scss'],
-    changeDetection: ChangeDetectionStrategy.OnPush,
+    changeDetection: ChangeDetectionStrategy.Default,
     providers: [
         {
             provide: NG_VALUE_ACCESSOR,
@@ -37,7 +37,7 @@ export class ChannelAssignmentControlComponent implements OnInit, ControlValueAc
             .userStatus()
             .single$.pipe(
                 map(({ userStatus }) =>
-                    userStatus.channels.filter(c =>
+                    userStatus.channels.filter((c) =>
                         this.includeDefaultChannel ? true : c.code !== DEFAULT_CHANNEL_CODE,
                     ),
                 ),
@@ -70,7 +70,7 @@ export class ChannelAssignmentControlComponent implements OnInit, ControlValueAc
 
     valueChanged(value: CurrentUserChannel[] | CurrentUserChannel | undefined) {
         if (Array.isArray(value)) {
-            this.onChange(value.map(c => c.id));
+            this.onChange(value.map((c) => c.id));
         } else {
             this.onChange([value ? value.id : undefined]);
         }

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

@@ -52,6 +52,7 @@ export class RoleDetailComponent extends BaseDetailComponent<Role> implements On
     ngOnInit() {
         this.init();
         this.role$ = this.entity$;
+        // setTimeout(() => this.changeDetector.markForCheck(), 2000);
     }
 
     ngOnDestroy(): void {
@@ -134,6 +135,10 @@ export class RoleDetailComponent extends BaseDetailComponent<Role> implements On
         for (const permission of Object.keys(this.permissions)) {
             this.permissions[permission] = role.permissions.includes(permission as Permission);
         }
+        // This was required to get the channel selector component to
+        // correctly display its contents. A while spent debugging the root
+        // cause did not yield a solution, therefore this next line.
+        this.changeDetector.detectChanges();
     }
 
     private getSelectedPermissions(): Permission[] {