From 2640b6eed0668f55d8852311c4e935ae095d7873 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sun, 10 Sep 2017 18:46:30 +0200 Subject: [PATCH] Bugfixes --- .../pages/users/user-page.component.ts | 6 +- .../pages/content/content-page.component.html | 4 -- .../pages/content/content-page.component.ts | 41 +++++-------- .../pages/contents/search-form.component.html | 40 ++++++++----- .../pages/contents/search-form.component.scss | 7 +++ .../pages/contents/search-form.component.ts | 8 ++- .../app/shared/components/asset.component.ts | 3 +- .../shared/services/assets.service.spec.ts | 9 ++- .../app/shared/services/assets.service.ts | 15 +++-- .../shared/services/contents.service.spec.ts | 52 ++++++++++++++-- .../app/shared/services/contents.service.ts | 60 +++++++++++++++---- .../shared/services/schemas.service.spec.ts | 44 +++++++------- 12 files changed, 188 insertions(+), 101 deletions(-) diff --git a/src/Squidex/app/features/administration/pages/users/user-page.component.ts b/src/Squidex/app/features/administration/pages/users/user-page.component.ts index 53400a0ef..eb8824a30 100644 --- a/src/Squidex/app/features/administration/pages/users/user-page.component.ts +++ b/src/Squidex/app/features/administration/pages/users/user-page.component.ts @@ -32,7 +32,6 @@ export class UserPageComponent extends ComponentBase implements OnInit { public currentUserId: string; public userFormSubmitted = false; public userForm: FormGroup; - public userId: string; public userFormError? = ''; public isCurrentUser = false; @@ -86,7 +85,7 @@ export class UserPageComponent extends ComponentBase implements OnInit { this.resetUserForm(error.displayMessage); }); } else { - this.userManagementService.putUser(this.userId, requestDto) + this.userManagementService.putUser(this.user.id, requestDto) .subscribe(() => { this.user = this.user.update( @@ -119,7 +118,6 @@ export class UserPageComponent extends ComponentBase implements OnInit { const input = this.user || {}; this.isNewMode = !this.user; - this.userId = input['id']; this.userForm = this.formBuilder.group({ email: [input['email'], @@ -143,7 +141,7 @@ export class UserPageComponent extends ComponentBase implements OnInit { ]] }); - this.isCurrentUser = this.userId === this.currentUserId; + this.isCurrentUser = this.user && this.user.id === this.currentUserId; this.resetUserForm(); } diff --git a/src/Squidex/app/features/content/pages/content/content-page.component.html b/src/Squidex/app/features/content/pages/content/content-page.component.html index 707b90122..a75d7e44a 100644 --- a/src/Squidex/app/features/content/pages/content/content-page.component.html +++ b/src/Squidex/app/features/content/pages/content/content-page.component.html @@ -38,10 +38,6 @@
-
- You have not created the subscription. Therefore you cannot change the plan. -
-
diff --git a/src/Squidex/app/features/content/pages/content/content-page.component.ts b/src/Squidex/app/features/content/pages/content/content-page.component.ts index 8645ebcfa..f0ffc00c6 100644 --- a/src/Squidex/app/features/content/pages/content/content-page.component.ts +++ b/src/Squidex/app/features/content/pages/content/content-page.component.ts @@ -40,15 +40,12 @@ import { export class ContentPageComponent extends AppComponentBase implements CanComponentDeactivate, OnDestroy, OnInit { private contentDeletedSubscription: Subscription; private contentVersionSelectedSubscription: Subscription; - private version = new Version(''); private content: ContentDto; public schema: SchemaDetailsDto; public contentFormSubmitted = false; public contentForm: FormGroup; - public contentData: any = null; - public contentId: string | null = null; public isNewMode = true; @@ -83,7 +80,7 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone this.contentDeletedSubscription = this.messageBus.of(ContentDeleted) .subscribe(message => { - if (message.content.id === this.contentId) { + if (this.content && message.content.id === this.content.id) { this.router.navigate(['../'], { relativeTo: this.route }); } }); @@ -124,7 +121,7 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone if (this.isNewMode) { this.appNameOnce() - .switchMap(app => this.contentsService.postContent(app, this.schema.name, requestDto, publish, this.version)) + .switchMap(app => this.contentsService.postContent(app, this.schema.name, requestDto, publish)) .subscribe(dto => { this.content = dto; @@ -137,7 +134,7 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone }); } else { this.appNameOnce() - .switchMap(app => this.contentsService.putContent(app, this.schema.name, this.contentId!, requestDto, this.version)) + .switchMap(app => this.contentsService.putContent(app, this.schema.name, this.content.id, requestDto, this.content.version)) .subscribe(dto => { this.content = this.content.update(dto, this.authService.user!.token); @@ -158,7 +155,7 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone private loadVersion(version: number) { if (!this.isNewMode && this.content) { this.appNameOnce() - .switchMap(app => this.contentsService.getVersionData(app, this.schema.name, this.contentId!, new Version(version.toString()))) + .switchMap(app => this.contentsService.getVersionData(app, this.schema.name, this.content.id, new Version(version.toString()))) .subscribe(dto => { this.content = this.content.setData(dto); @@ -220,28 +217,20 @@ export class ContentPageComponent extends AppComponentBase implements CanCompone private populateContentForm() { this.contentForm.markAsPristine(); - if (!this.content) { - this.contentData = null; - this.contentId = null; - this.isNewMode = true; - return; - } - - this.contentData = this.content.data; - this.contentId = this.content.id; - this.version = this.content.version; - this.isNewMode = false; + this.isNewMode = !this.content; - for (const field of this.schema.fields) { - const fieldValue = this.content.data[field.name] || {}; - const fieldForm = this.contentForm.get(field.name); + if (!this.isNewMode) { + for (const field of this.schema.fields) { + const fieldValue = this.content.data[field.name] || {}; + const fieldForm = this.contentForm.get(field.name); - if (field.partitioning === 'language') { - for (let language of this.languages) { - fieldForm.controls[language.iso2Code].setValue(fieldValue[language.iso2Code]); + if (field.partitioning === 'language') { + for (let language of this.languages) { + fieldForm.controls[language.iso2Code].setValue(fieldValue[language.iso2Code]); + } + } else { + fieldForm.controls['iv'].setValue(fieldValue['iv']); } - } else { - fieldForm.controls['iv'].setValue(fieldValue['iv']); } } } diff --git a/src/Squidex/app/features/content/pages/contents/search-form.component.html b/src/Squidex/app/features/content/pages/contents/search-form.component.html index 8430ffbb9..1f92fda29 100644 --- a/src/Squidex/app/features/content/pages/contents/search-form.component.html +++ b/src/Squidex/app/features/content/pages/contents/search-form.component.html @@ -1,27 +1,35 @@ -
-
- +
+
+
+ -
- +
+ +
-
-
- +
+ -
- +
+ +
-
-
- - -
- +
+ + +
+ +
+ +
+ +