fix userpage

This commit is contained in:
_Bastler 2021-12-03 23:58:19 +01:00
parent d75fa5fe59
commit e7083fff11
2 changed files with 15 additions and 9 deletions

View File

@ -59,6 +59,11 @@
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
<section>
<mat-checkbox [checked]="userpage.divider" (change)="userpage.divider = $event.checked">{{'userpages.divider'
| i18n}}</mat-checkbox>
</section>
</mat-card-content> </mat-card-content>
<mat-card-actions fxLayout="row wrap" fxFlexFill> <mat-card-actions fxLayout="row wrap" fxFlexFill>
<button *ngIf="!working" mat-raised-button color="primary" [disabled]="form.invalid"> <button *ngIf="!working" mat-raised-button color="primary" [disabled]="form.invalid">

View File

@ -27,7 +27,6 @@ export class PageUserPageEdit implements OnInit, OnDestroy {
working: boolean = false; working: boolean = false;
form: FormGroup; form: FormGroup;
settings: any; settings: any;
index: number;
settingsSubscription: Subscription; settingsSubscription: Subscription;
@ -65,9 +64,8 @@ export class PageUserPageEdit implements OnInit, OnDestroy {
this.form.get('sorting').valueChanges.subscribe((value) => { this.form.get('sorting').valueChanges.subscribe((value) => {
this.sorting = value; this.sorting = value;
}); });
this.form.get('index').setValue(this.index);
this.form.get('index').valueChanges.subscribe((value) => { this.form.get('index').valueChanges.subscribe((value) => {
this.index = value; this.userpage.index = value;
}); });
this.name = this.route.snapshot.paramMap.get('name'); this.name = this.route.snapshot.paramMap.get('name');
@ -84,6 +82,10 @@ export class PageUserPageEdit implements OnInit, OnDestroy {
this.userpage = data; this.userpage = data;
this.entryType = this.userpage.entryType; this.entryType = this.userpage.entryType;
this.sorting = this.userpage.sorting; this.sorting = this.userpage.sorting;
this.form.get("name").setValue(this.userpage.name);
this.form.get("entryType").setValue(this.userpage.entryType);
this.form.get("sorting").setValue(this.userpage.sorting);
this.form.get("index").setValue(this.userpage.index);
}, (error) => { }, (error) => {
if (error.status == 404) { if (error.status == 404) {
this.notfound = true; this.notfound = true;
@ -96,13 +98,12 @@ export class PageUserPageEdit implements OnInit, OnDestroy {
this.userpage.tags = []; this.userpage.tags = [];
this.userpage.excludedTags = []; this.userpage.excludedTags = [];
this.userpage.index = 99; this.userpage.index = 99;
}
this.form.get("name").setValue(this.userpage.name); this.form.get("name").setValue(this.userpage.name);
this.form.get("entryType").setValue(this.userpage.entryType); this.form.get("entryType").setValue(this.userpage.entryType);
this.form.get("sorting").setValue(this.userpage.sorting); this.form.get("sorting").setValue(this.userpage.sorting);
this.form.get("index").setValue(this.userpage.index); this.form.get("index").setValue(this.userpage.index);
} }
}
hasError(controlName: string): boolean { hasError(controlName: string): boolean {
return this.form.controls[ controlName ].errors != null; return this.form.controls[ controlName ].errors != null;
@ -119,7 +120,7 @@ export class PageUserPageEdit implements OnInit, OnDestroy {
this.userpage.name = this.form.get("name").value; this.userpage.name = this.form.get("name").value;
this.userpage.entryType = this.entryType; this.userpage.entryType = this.entryType;
this.userpage.sorting = this.sorting; this.userpage.sorting = this.sorting;
this.userpage.index = this.index; this.userpage.index = this.form.get("index").value;
this.userPageService.createOrUpdate(this.userpage).subscribe((data) => { this.userPageService.createOrUpdate(this.userpage).subscribe((data) => {
this.userpage = data; this.userpage = data;