Browse Source

Getting rid of field names in API.

pull/516/head
Sebastian 6 years ago
parent
commit
0fd0bd924f
  1. 20
      backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/ConfigureUIFieldsDto.cs
  2. 9
      backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDetailsDto.cs
  3. 14
      backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/UpsertSchemaDto.cs

20
backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/ConfigureUIFieldsDto.cs

@ -5,9 +5,9 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System.Collections.Generic;
using Squidex.Domain.Apps.Core.Schemas; using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Entities.Schemas.Commands; using Squidex.Domain.Apps.Entities.Schemas.Commands;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Areas.Api.Controllers.Schemas.Models namespace Squidex.Areas.Api.Controllers.Schemas.Models
{ {
@ -16,16 +16,28 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
/// <summary> /// <summary>
/// The name of fields that are used in content lists. /// The name of fields that are used in content lists.
/// </summary> /// </summary>
public FieldNames? FieldsInLists { get; set; } public List<string>? FieldsInLists { get; set; }
/// <summary> /// <summary>
/// The name of fields that are used in content references. /// The name of fields that are used in content references.
/// </summary> /// </summary>
public FieldNames? FieldsInReferences { get; set; } public List<string>? FieldsInReferences { get; set; }
public ConfigureUIFields ToCommand() public ConfigureUIFields ToCommand()
{ {
return SimpleMapper.Map(this, new ConfigureUIFields()); var command = new ConfigureUIFields();
if (FieldsInLists != null)
{
command.FieldsInLists = new FieldNames(FieldsInLists);
}
if (FieldsInReferences != null)
{
command.FieldsInReferences = new FieldNames(FieldsInReferences);
}
return command;
} }
} }
} }

9
backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDetailsDto.cs

@ -7,7 +7,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Squidex.Domain.Apps.Core.Schemas; using System.Linq;
using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
using Squidex.Shared; using Squidex.Shared;
@ -35,13 +35,13 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
/// The name of fields that are used in content lists. /// The name of fields that are used in content lists.
/// </summary> /// </summary>
[Required] [Required]
public FieldNames FieldsInLists { get; set; } public List<string> FieldsInLists { get; set; }
/// <summary> /// <summary>
/// The name of fields that are used in content references. /// The name of fields that are used in content references.
/// </summary> /// </summary>
[Required] [Required]
public FieldNames FieldsInReferences { get; set; } public List<string> FieldsInReferences { get; set; }
/// <summary> /// <summary>
/// The list of fields. /// The list of fields.
@ -58,6 +58,9 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
SimpleMapper.Map(schema.SchemaDef.Scripts, result.Scripts); SimpleMapper.Map(schema.SchemaDef.Scripts, result.Scripts);
SimpleMapper.Map(schema.SchemaDef.Properties, result.Properties); SimpleMapper.Map(schema.SchemaDef.Properties, result.Properties);
result.FieldsInLists = schema.SchemaDef.FieldsInLists.ToList();
result.FieldsInReferences = schema.SchemaDef.FieldsInReferences.ToList();
if (schema.SchemaDef.PreviewUrls.Count > 0) if (schema.SchemaDef.PreviewUrls.Count > 0)
{ {
result.PreviewUrls = new Dictionary<string, string>(schema.SchemaDef.PreviewUrls); result.PreviewUrls = new Dictionary<string, string>(schema.SchemaDef.PreviewUrls);

14
backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/UpsertSchemaDto.cs

@ -27,12 +27,12 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
/// <summary> /// <summary>
/// The names of the fields that should be used in references. /// The names of the fields that should be used in references.
/// </summary> /// </summary>
public FieldNames? FieldsInReferences { get; set; } public List<string>? FieldsInReferences { get; set; }
/// <summary> /// <summary>
/// The names of the fields that should be shown in lists, including meta fields. /// The names of the fields that should be shown in lists, including meta fields.
/// </summary> /// </summary>
public FieldNames? FieldsInLists { get; set; } public List<string>? FieldsInLists { get; set; }
/// <summary> /// <summary>
/// Optional fields. /// Optional fields.
@ -72,6 +72,16 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
SimpleMapper.Map(dto.Scripts, command.Scripts); SimpleMapper.Map(dto.Scripts, command.Scripts);
} }
if (dto.FieldsInLists != null)
{
command.FieldsInLists = new FieldNames(dto.FieldsInLists);
}
if (dto.FieldsInReferences != null)
{
command.FieldsInReferences = new FieldNames(dto.FieldsInReferences);
}
if (dto.Fields != null) if (dto.Fields != null)
{ {
command.Fields = new List<UpsertSchemaField>(); command.Fields = new List<UpsertSchemaField>();

Loading…
Cancel
Save