mirror of https://github.com/Squidex/squidex.git
Browse Source
# Conflicts: # src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj # src/Squidex/Areas/Api/Config/Swagger/SwaggerExtensions.cs # src/Squidex/Areas/Api/Config/Swagger/SwaggerServices.cs # src/Squidex/Squidex.csprojpull/336/head
397 changed files with 7067 additions and 4555 deletions
@ -1,68 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Collections.Immutable; |
|||
|
|||
namespace Squidex.Domain.Apps.Core |
|||
{ |
|||
public abstract class DictionaryWrapper<TKey, TValue> : IReadOnlyDictionary<TKey, TValue> |
|||
{ |
|||
private readonly ImmutableDictionary<TKey, TValue> inner; |
|||
|
|||
public TValue this[TKey key] |
|||
{ |
|||
get { return inner[key]; } |
|||
} |
|||
|
|||
public IEnumerable<TKey> Keys |
|||
{ |
|||
get { return inner.Keys; } |
|||
} |
|||
|
|||
public IEnumerable<TValue> Values |
|||
{ |
|||
get { return inner.Values; } |
|||
} |
|||
|
|||
public int Count |
|||
{ |
|||
get { return inner.Count; } |
|||
} |
|||
|
|||
protected ImmutableDictionary<TKey, TValue> Inner |
|||
{ |
|||
get { return inner; } |
|||
} |
|||
|
|||
protected DictionaryWrapper(ImmutableDictionary<TKey, TValue> inner) |
|||
{ |
|||
this.inner = inner; |
|||
} |
|||
|
|||
public bool ContainsKey(TKey key) |
|||
{ |
|||
return inner.ContainsKey(key); |
|||
} |
|||
|
|||
public bool TryGetValue(TKey key, out TValue value) |
|||
{ |
|||
return inner.TryGetValue(key, out value); |
|||
} |
|||
|
|||
IEnumerator<KeyValuePair<TKey, TValue>> IEnumerable<KeyValuePair<TKey, TValue>>.GetEnumerator() |
|||
{ |
|||
return inner.GetEnumerator(); |
|||
} |
|||
|
|||
IEnumerator IEnumerable.GetEnumerator() |
|||
{ |
|||
return inner.GetEnumerator(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
namespace Squidex.Domain.Apps.Core.Schemas |
|||
{ |
|||
public interface IFieldSettings |
|||
{ |
|||
bool IsLocked { get; } |
|||
|
|||
bool IsDisabled { get; } |
|||
|
|||
bool IsHidden { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
namespace Squidex.Domain.Apps.Core.Schemas |
|||
{ |
|||
public enum TagsFieldEditor |
|||
{ |
|||
Tags, |
|||
Checkboxes, |
|||
Dropdown |
|||
} |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Squidex.Infrastructure.Queries; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.ValidateContent.Validators |
|||
{ |
|||
public sealed class UniqueValidator : IValidator |
|||
{ |
|||
public async Task ValidateAsync(object value, ValidationContext context, AddError addError) |
|||
{ |
|||
var count = context.Path.Count(); |
|||
|
|||
if (value != null && (count == 0 || (count == 2 && context.Path.Last() == InvariantPartitioning.Instance.Master.Key))) |
|||
{ |
|||
FilterNode filter = null; |
|||
|
|||
if (value is string s) |
|||
{ |
|||
filter = new FilterComparison(Path(context), FilterOperator.Equals, new FilterValue(s)); |
|||
} |
|||
else if (value is double d) |
|||
{ |
|||
filter = new FilterComparison(Path(context), FilterOperator.Equals, new FilterValue(d)); |
|||
} |
|||
|
|||
if (filter != null) |
|||
{ |
|||
var found = await context.GetContentIdsAsync(context.SchemaId, filter); |
|||
|
|||
if (found.Any(x => x != context.ContentId)) |
|||
{ |
|||
addError(context.Path, "Another content with the same value exists."); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
private static List<string> Path(ValidationContext context) |
|||
{ |
|||
return Enumerable.Repeat("Data", 1).Union(context.Path).ToList(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using NodaTime; |
|||
using Squidex.Infrastructure.Queries; |
|||
|
|||
namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Visitors |
|||
{ |
|||
internal sealed class AdaptionVisitor : TransformVisitor |
|||
{ |
|||
private readonly Func<IReadOnlyList<string>, IReadOnlyList<string>> pathConverter; |
|||
|
|||
public AdaptionVisitor(Func<IReadOnlyList<string>, IReadOnlyList<string>> pathConverter) |
|||
{ |
|||
this.pathConverter = pathConverter; |
|||
} |
|||
|
|||
public override FilterNode Visit(FilterComparison nodeIn) |
|||
{ |
|||
FilterComparison result; |
|||
|
|||
var value = nodeIn.Rhs.Value; |
|||
|
|||
if (value is Instant && |
|||
!string.Equals(nodeIn.Lhs[0], "mt", StringComparison.OrdinalIgnoreCase) && |
|||
!string.Equals(nodeIn.Lhs[0], "ct", StringComparison.OrdinalIgnoreCase)) |
|||
{ |
|||
result = new FilterComparison(pathConverter(nodeIn.Lhs), nodeIn.Operator, new FilterValue(value.ToString())); |
|||
} |
|||
else |
|||
{ |
|||
result = new FilterComparison(pathConverter(nodeIn.Lhs), nodeIn.Operator, nodeIn.Rhs); |
|||
} |
|||
|
|||
if (result.Lhs.Count == 1 && result.Lhs[0] == "_id" && result.Rhs.Value is List<Guid> guidList) |
|||
{ |
|||
result = new FilterComparison(nodeIn.Lhs, nodeIn.Operator, new FilterValue(guidList.Select(x => x.ToString()).ToList())); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue