// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.Immutable;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using NJsonSchema.Annotations;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Areas.Api.Controllers.Schemas.Models.Fields
{
[JsonSchema("Number")]
public sealed class NumberFieldPropertiesDto : FieldPropertiesDto
{
///
/// The default value for the field value.
///
public double? DefaultValue { get; set; }
///
/// The maximum allowed value for the field value.
///
public double? MaxValue { get; set; }
///
/// The minimum allowed value for the field value.
///
public double? MinValue { get; set; }
///
/// The allowed values for the field value.
///
public double[] AllowedValues { get; set; }
///
/// Indicates that the inline editor is enabled for this field.
///
public bool InlineEditable { get; set; }
///
/// The editor that is used to manage this field.
///
[JsonConverter(typeof(StringEnumConverter))]
public NumberFieldEditor Editor { get; set; }
public override FieldProperties ToProperties()
{
var result = SimpleMapper.Map(this, new NumberFieldProperties());
if (AllowedValues != null)
{
result.AllowedValues = ImmutableList.Create(AllowedValues);
}
return result;
}
}
}