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; } public JsonFieldModel[] Fields { get; set; }
[JsonProperty] [JsonProperty]
public IReadOnlyDictionary<string, string> PreviewUrls { get; set; } public Dictionary<string, string> PreviewUrls { get; set; }
public JsonSchemaModel() public JsonSchemaModel()
{ {
@ -61,6 +61,8 @@ namespace Squidex.Domain.Apps.Core.Schemas.Json
Partitioning = x.Partitioning.Key, Partitioning = x.Partitioning.Key,
Properties = x.RawProperties Properties = x.RawProperties
}); });
PreviewUrls = schema.PreviewUrls.ToDictionary(x => x.Key, x => x.Value);
} }
private static JsonNestedFieldModel[] CreateChildren(IField field) 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) public SchemaHistoryEventsCreator(TypeNameRegistry typeNameRegistry)
: base(typeNameRegistry) : base(typeNameRegistry)
{ {
AddEventMessage("SchemaCreated", AddEventMessage("SchemaCreatedEvent",
"created schema {[Name]}."); "created schema {[Name]}.");
AddEventMessage("ScriptsConfigured", AddEventMessage("ScriptsConfiguredEvent",
"configured script of schema {[Name]}."); "configured script of schema {[Name]}.");
AddEventMessage<SchemaFieldsReordered>( 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; } public SchemaPropertiesDto Properties { get; set; }
/// <summary> /// <summary>
/// Optional fields. /// The optional scripts.
/// </summary> /// </summary>
public List<UpsertSchemaFieldDto> Fields { get; set; } public SchemaScriptsDto Scripts { get; set; }
/// <summary> /// <summary>
/// The optional scripts. /// Optional fields.
/// </summary> /// </summary>
public Dictionary<string, string> Scripts { get; set; } public List<UpsertSchemaFieldDto> Fields { get; set; }
/// <summary> /// <summary>
/// The optional preview urls. /// The optional preview urls.
@ -55,23 +55,34 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
SimpleMapper.Map(dto.Properties, command.Properties); SimpleMapper.Map(dto.Properties, command.Properties);
} }
if (dto.Scripts != null)
{
command.Scripts = new SchemaScripts();
SimpleMapper.Map(dto.Scripts, command.Scripts);
}
if (dto.Fields != null) if (dto.Fields != null)
{ {
command.Fields = new List<UpsertSchemaField>(); command.Fields = new List<UpsertSchemaField>();
foreach (var fieldDto in dto.Fields) foreach (var rootFieldDto in dto.Fields)
{ {
var rootProperties = fieldDto?.Properties.ToProperties(); var rootProps = rootFieldDto?.Properties.ToProperties();
var rootField = SimpleMapper.Map(fieldDto, new UpsertSchemaField { Properties = rootProperties }); var rootField = new UpsertSchemaField { Properties = rootProps };
SimpleMapper.Map(rootFieldDto, rootField);
if (fieldDto.Nested != null) if (rootFieldDto.Nested?.Count > 0)
{ {
rootField.Nested = new List<UpsertSchemaNestedField>(); rootField.Nested = new List<UpsertSchemaNestedField>();
foreach (var nestedFieldDto in fieldDto.Nested) foreach (var nestedFieldDto in rootFieldDto.Nested)
{ {
var nestedProperties = nestedFieldDto?.Properties.ToProperties(); var nestedProps = nestedFieldDto?.Properties.ToProperties();
var nestedField = SimpleMapper.Map(nestedFieldDto, new UpsertSchemaNestedField { Properties = nestedProperties }); var nestedField = new UpsertSchemaNestedField { Properties = nestedProps };
SimpleMapper.Map(nestedFieldDto, nestedField);
rootField.Nested.Add(nestedField); rootField.Nested.Add(nestedField);
} }

1
tools/Migrate_01/OldEvents/ScriptsConfigured.cs

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

Loading…
Cancel
Save