diff --git a/backend/src/Squidex.Web/ApiExceptionConverter.cs b/backend/src/Squidex.Web/ApiExceptionConverter.cs index 7eb02cd9b..bd1fdbb70 100644 --- a/backend/src/Squidex.Web/ApiExceptionConverter.cs +++ b/backend/src/Squidex.Web/ApiExceptionConverter.cs @@ -1,4 +1,4 @@ -// ========================================================================== +// ========================================================================== // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex UG (haftungsbeschraenkt) @@ -84,31 +84,31 @@ namespace Squidex.Web switch (exception) { case ValidationException ex: - return (CreateError(400, T.Get("common.httpValidationError"), ToErrors(ex.Errors).ToArray()), true); + return (CreateError(400, T.Get("common.httpValidationError"), null, ToErrors(ex.Errors)), true); case DomainObjectNotFoundException ex: - return (CreateError(404, errorCode: ex.ErrorCode), true); + return (CreateError(404, ex.ErrorCode), true); case DomainObjectVersionException ex: - return (CreateError(412, exception.Message, errorCode: ex.ErrorCode), true); + return (CreateError(412, ex.Message, ex.ErrorCode), true); case DomainObjectDeletedException ex: - return (CreateError(410, exception.Message, errorCode: ex.ErrorCode), true); + return (CreateError(410, ex.Message, ex.ErrorCode), true); case DomainObjectConflictException ex: - return (CreateError(409, exception.Message, errorCode: ex.ErrorCode), true); + return (CreateError(409, ex.Message, ex.ErrorCode), true); case DomainForbiddenException ex: - return (CreateError(403, exception.Message, errorCode: ex.ErrorCode), true); + return (CreateError(403, ex.Message, ex.ErrorCode), true); case DomainException ex: - return (CreateError(400, exception.Message, errorCode: ex.ErrorCode), true); + return (CreateError(400, ex.Message, ex.ErrorCode), true); case SecurityException: return (CreateError(403), false); - case DecoderFallbackException: - return (CreateError(400, exception.Message), true); + case DecoderFallbackException ex: + return (CreateError(400, ex.Message), true); case BadHttpRequestException ex: return (CreateError(ex.StatusCode, ex.Message), true); @@ -118,9 +118,16 @@ namespace Squidex.Web } } - private static ErrorDto CreateError(int status, string? message = null, string[]? details = null, string? errorCode = null) + private static ErrorDto CreateError(int status, string? message = null, string? errorCode = null, IEnumerable? details = null) { - var error = new ErrorDto { StatusCode = status, Message = message, Details = details, ErrorCode = errorCode }; + var error = new ErrorDto { StatusCode = status, Message = message }; + + if (!string.IsNullOrWhiteSpace(errorCode)) + { + error.ErrorCode = errorCode; + } + + error.Details = details?.ToArray(); return error; } diff --git a/frontend/app/features/content/shared/references/content-creator.component.ts b/frontend/app/features/content/shared/references/content-creator.component.ts index 8a2226820..358c0ca7c 100644 --- a/frontend/app/features/content/shared/references/content-creator.component.ts +++ b/frontend/app/features/content/shared/references/content-creator.component.ts @@ -20,6 +20,12 @@ export class ContentCreatorComponent extends ResourceOwner implements OnInit { @Output() public select = new EventEmitter>(); + @Input() + public initialData: any; + + @Input() + public schemaName: string; + @Input() public schemaIds: ReadonlyArray; @@ -52,7 +58,9 @@ export class ContentCreatorComponent extends ResourceOwner implements OnInit { this.schemas = this.schemas.filter(x => this.schemaIds.indexOf(x.id) >= 0); } - this.selectSchema(this.schemas[0]); + const selectedSchema = this.schemas.find(x => x.name === this.schemaName) || this.schemas[0]; + + this.selectSchema(selectedSchema); } public selectSchema(selected: string | SchemaDto) { @@ -68,6 +76,12 @@ export class ContentCreatorComponent extends ResourceOwner implements OnInit { this.contentsState.schema = schema; this.contentForm = new EditContentForm(this.languages, this.schema, { user: this.formContext.user }); + if (this.initialData) { + this.contentForm.load(this.initialData, true); + + this.initialData = null; + } + this.changeDetector.markForCheck(); } }); diff --git a/frontend/app/features/content/shared/references/reference-item.component.html b/frontend/app/features/content/shared/references/reference-item.component.html index c3afb7707..625a4493f 100644 --- a/frontend/app/features/content/shared/references/reference-item.component.html +++ b/frontend/app/features/content/shared/references/reference-item.component.html @@ -31,6 +31,10 @@
+ + diff --git a/frontend/app/features/content/shared/references/reference-item.component.ts b/frontend/app/features/content/shared/references/reference-item.component.ts index e7193d71d..237bd84ba 100644 --- a/frontend/app/features/content/shared/references/reference-item.component.ts +++ b/frontend/app/features/content/shared/references/reference-item.component.ts @@ -20,6 +20,9 @@ export class ReferenceItemComponent implements OnChanges { @Output() public delete = new EventEmitter(); + @Output() + public clone = new EventEmitter(); + @Input() public language: AppLanguageDto; diff --git a/frontend/app/features/content/shared/references/references-editor.component.html b/frontend/app/features/content/shared/references/references-editor.component.html index fb5b08b22..c00c18916 100644 --- a/frontend/app/features/content/shared/references/references-editor.component.html +++ b/frontend/app/features/content/shared/references/references-editor.component.html @@ -5,7 +5,7 @@
- {{ 'contents.referencesCreateNew' | sqxTranslate }} + {{ 'contents.referencesCreateNew' | sqxTranslate }} · @@ -23,6 +23,7 @@ class="table-drag" cdkDrag cdkDragLockAxis="y" + (clone)="createContent(content)" [columns]="snapshot.contentItems | sqxContentsColumns" [isCompact]="snapshot.isCompact" [isDisabled]="snapshot.isDisabled" @@ -38,8 +39,10 @@ diff --git a/frontend/app/features/content/shared/references/references-editor.component.ts b/frontend/app/features/content/shared/references/references-editor.component.ts index b1cc37ac8..4a8b424c1 100644 --- a/frontend/app/features/content/shared/references/references-editor.component.ts +++ b/frontend/app/features/content/shared/references/references-editor.component.ts @@ -52,6 +52,8 @@ export class ReferencesEditorComponent extends StatefulControlComponent x.id);