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 366529a50..0c95223a9 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 @@ -46,11 +46,9 @@ export class ContentPageComponent extends AppComponentBase implements OnDestroy, public contentData: any = null; public contentId: string; - public languages: AppLanguageDto[] = []; + public isNewMode = false; - public get isNewMode() { - return !this.contentData; - } + public languages: AppLanguageDto[] = []; constructor(apps: AppsStoreService, notifications: NotificationService, users: UsersProviderService, private readonly contentsService: ContentsService, @@ -182,10 +180,12 @@ export class ContentPageComponent extends AppComponentBase implements OnDestroy, if (!content) { this.contentData = undefined; this.contentId = undefined; + this.isNewMode = false; return; } else { this.contentData = content.data; this.contentId = content.id; + this.isNewMode = true; } for (const field of this.schema.fields) { diff --git a/src/Squidex/app/features/content/pages/contents/content-item.component.html b/src/Squidex/app/features/content/pages/contents/content-item.component.html index 0b4af0643..30edecfe5 100644 --- a/src/Squidex/app/features/content/pages/contents/content-item.component.html +++ b/src/Squidex/app/features/content/pages/contents/content-item.component.html @@ -1,6 +1,6 @@ - + - {{getValue(field)}} + {{value}} @@ -16,13 +16,13 @@ diff --git a/src/Squidex/app/features/content/pages/contents/content-item.component.ts b/src/Squidex/app/features/content/pages/contents/content-item.component.ts index db275740d..ede05df78 100644 --- a/src/Squidex/app/features/content/pages/contents/content-item.component.ts +++ b/src/Squidex/app/features/content/pages/contents/content-item.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Sebastian Stehle. All rights reserved */ -import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { AppComponentBase, @@ -28,17 +28,17 @@ import { fadeAnimation ] }) -export class ContentItemComponent extends AppComponentBase { +export class ContentItemComponent extends AppComponentBase implements OnInit { public dropdown = new ModalView(false, true); @Output() - public published = new EventEmitter(); + public publishing = new EventEmitter(); @Output() - public unpublished = new EventEmitter(); + public unpublishing = new EventEmitter(); @Output() - public deleted = new EventEmitter(); + public deleting = new EventEmitter(); @Input() public fields: FieldDto[]; @@ -52,10 +52,18 @@ export class ContentItemComponent extends AppComponentBase { @Input('sqxContent') public content: ContentDto; + public values: any[] = []; + constructor(apps: AppsStoreService, notifications: NotificationService, users: UsersProviderService) { super(apps, notifications, users); } + public ngOnInit() { + for (let field of this.fields) { + this.values.push(this.getValue(field)); + } + } + public getValue(field: FieldDto): any { const contentField = this.content.data[field.name]; diff --git a/src/Squidex/app/features/content/pages/contents/contents-page.component.html b/src/Squidex/app/features/content/pages/contents/contents-page.component.html index da7114d3b..d5bcd7299 100644 --- a/src/Squidex/app/features/content/pages/contents/contents-page.component.html +++ b/src/Squidex/app/features/content/pages/contents/contents-page.component.html @@ -57,9 +57,9 @@ [language]="languageSelected" [fields]="contentFields" [schema]="schema" - (unpublished)="unpublishContent(content)" - (published)="publishContent(content)" - (deleted)="deleteContent(content)"> + (unpublishing)="unpublishContent(content)" + (publishing)="publishContent(content)" + (deleting)="deleteContent(content)"> diff --git a/src/Squidex/app/features/content/pages/contents/contents-page.component.ts b/src/Squidex/app/features/content/pages/contents/contents-page.component.ts index 058030d68..a4738be00 100644 --- a/src/Squidex/app/features/content/pages/contents/contents-page.component.ts +++ b/src/Squidex/app/features/content/pages/contents/contents-page.component.ts @@ -82,17 +82,17 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy } public ngOnInit() { - this.messageUpdatedSubscription = - this.messageBus.of(ContentUpdated).subscribe(message => { - this.contentItems = this.contentItems.replaceAll(x => x.id === message.id, c => this.updateContent(c, true, message.data)); - }); - this.messageCreatedSubscription = this.messageBus.of(ContentCreated).subscribe(message => { this.contentTotal++; this.contentItems = this.contentItems.pushFront(this.createContent(message.id, message.data)); }); + this.messageUpdatedSubscription = + this.messageBus.of(ContentUpdated).subscribe(message => { + this.updateContents(message.id, true, message.data); + }); + this.route.data.map(p => p['appLanguages']).subscribe((languages: AppLanguageDto[]) => { this.languages = languages; }); @@ -117,7 +117,7 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy this.appName() .switchMap(app => this.contentsService.publishContent(app, this.schema.name, content.id)) .subscribe(() => { - this.contentItems = this.contentItems.replaceAll(x => x.id === content.id, c => this.updateContent(c, true, content.data)); + this.updateContents(content.id, true, content.data); }, error => { this.notifyError(error); }); @@ -127,7 +127,7 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy this.appName() .switchMap(app => this.contentsService.unpublishContent(app, this.schema.name, content.id)) .subscribe(() => { - this.contentItems = this.contentItems.replaceAll(x => x.id === content.id, c => this.updateContent(c, false, content.data)); + this.updateContents(content.id, false, content.data); }, error => { this.notifyError(error); }); @@ -204,6 +204,10 @@ export class ContentsPageComponent extends AppComponentBase implements OnDestroy this.canGoPrev = this.currentPage > 0; } + private updateContents(id: string, isPublished: boolean, data: any) { + this.contentItems = this.contentItems.replaceAll(x => x.id === id, c => this.updateContent(c, isPublished, data)); + } + private createContent(id: string, data: any): ContentDto { const me = `subject:${this.authService.user!.id}`; diff --git a/src/Squidex/app/features/schemas/pages/schema/field.component.html b/src/Squidex/app/features/schemas/pages/schema/field.component.html index 461e5b45d..3bf045c2a 100644 --- a/src/Squidex/app/features/schemas/pages/schema/field.component.html +++ b/src/Squidex/app/features/schemas/pages/schema/field.component.html @@ -26,19 +26,19 @@ diff --git a/src/Squidex/app/features/schemas/pages/schema/field.component.ts b/src/Squidex/app/features/schemas/pages/schema/field.component.ts index 23c649520..63736fe33 100644 --- a/src/Squidex/app/features/schemas/pages/schema/field.component.ts +++ b/src/Squidex/app/features/schemas/pages/schema/field.component.ts @@ -30,22 +30,22 @@ export class FieldComponent implements OnInit { public field: FieldDto; @Output() - public hidden = new EventEmitter(); + public hiding = new EventEmitter(); @Output() - public shown = new EventEmitter(); + public showing = new EventEmitter(); @Output() - public saved = new EventEmitter(); + public saving= new EventEmitter(); @Output() - public enabled = new EventEmitter(); + public enabling = new EventEmitter(); @Output() - public disabled = new EventEmitter(); + public disabling = new EventEmitter(); @Output() - public deleted = new EventEmitter(); + public deleting = new EventEmitter(); public isEditing: boolean = false; public selectedTab = 0; @@ -93,7 +93,7 @@ export class FieldComponent implements OnInit { this.field.isHidden, properties); - this.saved.emit(field); + this.saving.emit(field); } } diff --git a/src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts b/src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts index 0a1e18dcb..ad015afef 100644 --- a/src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts +++ b/src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.ts @@ -59,6 +59,11 @@ export class SchemaEditFormComponent implements OnInit { this.editForm.patchValue(this.schema); } + public cancel() { + this.reset(); + this.cancelled.emit(); + } + public saveSchema() { this.editFormSubmitted = true; @@ -78,13 +83,8 @@ export class SchemaEditFormComponent implements OnInit { } } - public reset() { + private reset() { this.editFormSubmitted = false; this.editForm.reset(); } - - public cancel() { - this.reset(); - this.cancelled.emit(); - } } \ No newline at end of file diff --git a/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html b/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html index b221b9ccf..66f082e51 100644 --- a/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html +++ b/src/Squidex/app/features/schemas/pages/schema/schema-page.component.html @@ -28,12 +28,12 @@
+ (disabling)="disableField(field)" + (deleting)="deleteField(field)" + (enabling)="enableField(field)" + (showing)="showField(field)" + (hiding)="hideField(field)" + (saving)="saveField(field, $event)">
- +