From 36f15a87ce3f306636bd99e61c29e93386c0d325 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Wed, 6 Nov 2019 20:06:35 +0100 Subject: [PATCH] Fallback handling for list fields. --- .../Schemas/FieldProperties.cs | 7 +++++++ .../Schemas/Json/JsonSchemaModel.cs | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldProperties.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldProperties.cs index ae03e8cd4..3a8af41e5 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldProperties.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldProperties.cs @@ -5,12 +5,19 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== +using System; using System.Collections.ObjectModel; namespace Squidex.Domain.Apps.Core.Schemas { public abstract class FieldProperties : NamedElementPropertiesBase { + [Obsolete] + public bool IsListField { get; set; } + + [Obsolete] + public bool IsReferenceField { get; set; } + public bool IsRequired { get; set; } public string? Placeholder { get; set; } diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/JsonSchemaModel.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/JsonSchemaModel.cs index 596d9dc4d..8946a9f5b 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/JsonSchemaModel.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Schemas/Json/JsonSchemaModel.cs @@ -12,6 +12,8 @@ using Newtonsoft.Json; using Squidex.Infrastructure; using Squidex.Infrastructure.Reflection; +#pragma warning disable CS0612 // Type or member is obsolete + namespace Squidex.Domain.Apps.Core.Schemas.Json { public sealed class JsonSchemaModel @@ -106,11 +108,21 @@ namespace Squidex.Domain.Apps.Core.Schemas.Json schema = schema.ConfigureScripts(Scripts); } + if (FieldsInLists == null) + { + FieldsInLists = new FieldNames(Fields.Where(x => x.Properties.IsListField).Select(x => x.Name).ToArray()); + } + if (FieldsInLists?.Count > 0) { schema = schema.ConfigureFieldsInLists(FieldsInLists); } + if (FieldsInReferences == null) + { + FieldsInLists = new FieldNames(Fields.Where(x => x.Properties.IsReferenceField).Select(x => x.Name).ToArray()); + } + if (FieldsInReferences?.Count > 0) { schema = schema.ConfigureFieldsInReferences(FieldsInReferences);