Browse Source

Small fixes.

pull/343/head
Sebastian Stehle 7 years ago
parent
commit
a360f0fb7b
  1. 4
      src/Squidex.Domain.Apps.Core.Model/Schemas/Json/JsonSchemaModel.cs
  2. 4
      src/Squidex.Domain.Apps.Entities/Schemas/SchemaHistoryEventsCreator.cs
  3. 33
      src/Squidex/Areas/Api/Controllers/Schemas/Models/UpsertDto.cs
  4. 1
      tools/Migrate_01/OldEvents/ScriptsConfigured.cs

4
src/Squidex.Domain.Apps.Core.Model/Schemas/Json/JsonSchemaModel.cs

@ -38,7 +38,7 @@ namespace Squidex.Domain.Apps.Core.Schemas.Json
public JsonFieldModel[] Fields { get; set; }
[JsonProperty]
public IReadOnlyDictionary<string, string> PreviewUrls { get; set; }
public Dictionary<string, string> PreviewUrls { get; set; }
public JsonSchemaModel()
{
@ -61,6 +61,8 @@ namespace Squidex.Domain.Apps.Core.Schemas.Json
Partitioning = x.Partitioning.Key,
Properties = x.RawProperties
});
PreviewUrls = schema.PreviewUrls.ToDictionary(x => x.Key, x => x.Value);
}
private static JsonNestedFieldModel[] CreateChildren(IField field)

4
src/Squidex.Domain.Apps.Entities/Schemas/SchemaHistoryEventsCreator.cs

@ -19,10 +19,10 @@ namespace Squidex.Domain.Apps.Entities.Schemas
public SchemaHistoryEventsCreator(TypeNameRegistry typeNameRegistry)
: base(typeNameRegistry)
{
AddEventMessage("SchemaCreated",
AddEventMessage("SchemaCreatedEvent",
"created schema {[Name]}.");
AddEventMessage("ScriptsConfigured",
AddEventMessage("ScriptsConfiguredEvent",
"configured script of schema {[Name]}.");
AddEventMessage<SchemaFieldsReordered>(

33
src/Squidex/Areas/Api/Controllers/Schemas/Models/UpsertDto.cs

@ -20,14 +20,14 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
public SchemaPropertiesDto Properties { get; set; }
/// <summary>
/// Optional fields.
/// The optional scripts.
/// </summary>
public List<UpsertSchemaFieldDto> Fields { get; set; }
public SchemaScriptsDto Scripts { get; set; }
/// <summary>
/// The optional scripts.
/// Optional fields.
/// </summary>
public Dictionary<string, string> Scripts { get; set; }
public List<UpsertSchemaFieldDto> Fields { get; set; }
/// <summary>
/// The optional preview urls.
@ -55,23 +55,34 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
SimpleMapper.Map(dto.Properties, command.Properties);
}
if (dto.Scripts != null)
{
command.Scripts = new SchemaScripts();
SimpleMapper.Map(dto.Scripts, command.Scripts);
}
if (dto.Fields != null)
{
command.Fields = new List<UpsertSchemaField>();
foreach (var fieldDto in dto.Fields)
foreach (var rootFieldDto in dto.Fields)
{
var rootProperties = fieldDto?.Properties.ToProperties();
var rootField = SimpleMapper.Map(fieldDto, new UpsertSchemaField { Properties = rootProperties });
var rootProps = rootFieldDto?.Properties.ToProperties();
var rootField = new UpsertSchemaField { Properties = rootProps };
SimpleMapper.Map(rootFieldDto, rootField);
if (fieldDto.Nested != null)
if (rootFieldDto.Nested?.Count > 0)
{
rootField.Nested = new List<UpsertSchemaNestedField>();
foreach (var nestedFieldDto in fieldDto.Nested)
foreach (var nestedFieldDto in rootFieldDto.Nested)
{
var nestedProperties = nestedFieldDto?.Properties.ToProperties();
var nestedField = SimpleMapper.Map(nestedFieldDto, new UpsertSchemaNestedField { Properties = nestedProperties });
var nestedProps = nestedFieldDto?.Properties.ToProperties();
var nestedField = new UpsertSchemaNestedField { Properties = nestedProps };
SimpleMapper.Map(nestedFieldDto, nestedField);
rootField.Nested.Add(nestedField);
}

1
tools/Migrate_01/OldEvents/ScriptsConfigured.cs

@ -6,7 +6,6 @@
// ==========================================================================
using System;
using System.Collections.Generic;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Schemas;

Loading…
Cancel
Save