Updated to reflect renamed schemas

This commit is contained in:
tanshu 2020-05-11 22:42:13 +05:30
parent 07b7248b4e
commit 02fbd0984e
2 changed files with 9 additions and 9 deletions

View File

@ -25,11 +25,11 @@
<mat-checkbox formControlName="lockedOut">Is Locked Out?</mat-checkbox>
</div>
<mat-divider></mat-divider>
<div formArrayName="groups">
<div fxLayout="row" *ngFor="let g of item.groups; index as i" [formGroupName]="i" fxLayout="row"
<div formArrayName="roles">
<div fxLayout="row" *ngFor="let r of item.roles; index as i" [formGroupName]="i" fxLayout="row"
fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
fxLayoutGap.lt-md="0px">
<mat-checkbox formControlName="group" fxFlex>{{g.name}}</mat-checkbox>
<mat-checkbox formControlName="group" fxFlex>{{r.name}}</mat-checkbox>
</div>
</div>
</form>

View File

@ -36,7 +36,7 @@ export class UserDetailComponent implements OnInit, AfterViewInit {
name: '',
password: '',
lockedOut: '',
groups: this.fb.array([])
roles: this.fb.array([])
});
}
@ -52,10 +52,10 @@ export class UserDetailComponent implements OnInit, AfterViewInit {
this.form.get('name').setValue(item.name);
this.form.get('password').setValue('');
this.form.get('lockedOut').setValue(item.lockedOut);
this.form.setControl('groups', this.fb.array(
item.groups.map(
this.form.setControl('roles', this.fb.array(
item.roles.map(
x => this.fb.group({
group: x.enabled
role: x.enabled
})
)
));
@ -112,8 +112,8 @@ export class UserDetailComponent implements OnInit, AfterViewInit {
this.item.name = formModel.name;
this.item.password = formModel.password;
this.item.lockedOut = formModel.lockedOut;
const array = this.form.get('groups') as FormArray;
this.item.groups.forEach((item, index) => {
const array = this.form.get('roles') as FormArray;
this.item.roles.forEach((item, index) => {
item.enabled = array.controls[index].value.group;
});
return this.item;