From b9632ca0e2926750bb476e5af66047c844e07006 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Mon, 27 Nov 2017 21:18:45 +0100 Subject: [PATCH] Added button to clone a schema. --- .../Models/Converters/SchemaConverter.cs | 5 +++++ .../app/features/schemas/pages/messages.ts | 7 +++++++ .../pages/schema/schema-page.component.html | 5 +++++ .../pages/schema/schema-page.component.ts | 5 +++++ .../pages/schemas/schema-form.component.ts | 13 +++++++++++-- .../pages/schemas/schemas-page.component.html | 6 ++++-- .../pages/schemas/schemas-page.component.ts | 17 +++++++++++++++++ 7 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/Squidex/Areas/Api/Controllers/Schemas/Models/Converters/SchemaConverter.cs b/src/Squidex/Areas/Api/Controllers/Schemas/Models/Converters/SchemaConverter.cs index 3183569b1..7233f65bc 100644 --- a/src/Squidex/Areas/Api/Controllers/Schemas/Models/Converters/SchemaConverter.cs +++ b/src/Squidex/Areas/Api/Controllers/Schemas/Models/Converters/SchemaConverter.cs @@ -7,6 +7,7 @@ // ========================================================================== using System.Collections.Generic; +using Squidex.Domain.Apps.Core.Schemas; using Squidex.Domain.Apps.Read.Schemas; using Squidex.Domain.Apps.Write.Schemas.Commands; using Squidex.Infrastructure.Reflection; @@ -61,11 +62,15 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models.Converters if (dto.Properties != null) { + command.Properties = new SchemaProperties(); + SimpleMapper.Map(dto.Properties, command.Properties); } if (dto.Fields != null) { + command.Fields = new List(); + foreach (var fieldDto in dto.Fields) { var fieldProperties = fieldDto?.Properties.ToProperties(); diff --git a/src/Squidex/app/features/schemas/pages/messages.ts b/src/Squidex/app/features/schemas/pages/messages.ts index 3702b2933..0ab1ed9f0 100644 --- a/src/Squidex/app/features/schemas/pages/messages.ts +++ b/src/Squidex/app/features/schemas/pages/messages.ts @@ -26,4 +26,11 @@ export class SchemaDeleted { public readonly schema: SchemaDto ) { } +} + +export class SchemaCloning { + constructor( + public readonly importing: any + ) { + } } \ 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 12674ac1d..8415c4ac2 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 @@ -25,6 +25,11 @@ Scripts + + + Clone + + (); @Output() public cancelled = new EventEmitter(); + @Input() + public import: any; + public showImport = false; public createFormError = ''; @@ -65,6 +68,12 @@ export class SchemaFormComponent { ) { } + public ngOnInit() { + this.createForm.controls['import'].setValue(this.import || {}); + + this.showImport = !!this.import; + } + public toggleImport() { this.showImport = !this.showImport; diff --git a/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.html b/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.html index 39ce9a103..d6c3e2844 100644 --- a/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.html +++ b/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.html @@ -14,7 +14,7 @@ - @@ -58,7 +58,8 @@