mirror of https://github.com/Squidex/squidex.git
23 changed files with 467 additions and 89 deletions
@ -0,0 +1,145 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.Schemas |
|||
{ |
|||
public static class FieldExtensions |
|||
{ |
|||
public static Schema LockField(this Schema schema, long fieldId) |
|||
{ |
|||
return schema.UpdateField(fieldId, f => f.Lock()); |
|||
} |
|||
|
|||
public static Schema ReorderFields(this Schema schema, List<long> ids, long? parentId = null) |
|||
{ |
|||
if (parentId != null) |
|||
{ |
|||
return schema.UpdateField(parentId.Value, f => |
|||
{ |
|||
if (f is ArrayField arrayField) |
|||
{ |
|||
return arrayField.ReorderFields(ids); |
|||
} |
|||
|
|||
return f; |
|||
}); |
|||
} |
|||
|
|||
return schema.ReorderFields(ids); |
|||
} |
|||
|
|||
public static Schema DeleteField(this Schema schema, long fieldId, long? parentId = null) |
|||
{ |
|||
if (parentId != null) |
|||
{ |
|||
return schema.UpdateField(parentId.Value, f => |
|||
{ |
|||
if (f is ArrayField arrayField) |
|||
{ |
|||
return arrayField.DeleteField(fieldId); |
|||
} |
|||
|
|||
return f; |
|||
}); |
|||
} |
|||
|
|||
return schema.DeleteField(fieldId); |
|||
} |
|||
|
|||
public static Schema HideField(this Schema schema, long fieldId, long? parentId = null) |
|||
{ |
|||
if (parentId != null) |
|||
{ |
|||
return schema.UpdateField(parentId.Value, f => |
|||
{ |
|||
if (f is ArrayField arrayField) |
|||
{ |
|||
return arrayField.UpdateField(fieldId, n => n.Hide()); |
|||
} |
|||
|
|||
return f; |
|||
}); |
|||
} |
|||
|
|||
return schema.UpdateField(fieldId, f => f.Hide()); |
|||
} |
|||
|
|||
public static Schema ShowField(this Schema schema, long fieldId, long? parentId = null) |
|||
{ |
|||
if (parentId != null) |
|||
{ |
|||
return schema.UpdateField(parentId.Value, f => |
|||
{ |
|||
if (f is ArrayField arrayField) |
|||
{ |
|||
return arrayField.UpdateField(fieldId, n => n.Show()); |
|||
} |
|||
|
|||
return f; |
|||
}); |
|||
} |
|||
|
|||
return schema.UpdateField(fieldId, f => f.Show()); |
|||
} |
|||
|
|||
public static Schema EnableField(this Schema schema, long fieldId, long? parentId = null) |
|||
{ |
|||
if (parentId != null) |
|||
{ |
|||
return schema.UpdateField(parentId.Value, f => |
|||
{ |
|||
if (f is ArrayField arrayField) |
|||
{ |
|||
return arrayField.UpdateField(fieldId, n => n.Enable()); |
|||
} |
|||
|
|||
return f; |
|||
}); |
|||
} |
|||
|
|||
return schema.UpdateField(fieldId, f => f.Enable()); |
|||
} |
|||
|
|||
public static Schema DisableField(this Schema schema, long fieldId, long? parentId = null) |
|||
{ |
|||
if (parentId != null) |
|||
{ |
|||
return schema.UpdateField(parentId.Value, f => |
|||
{ |
|||
if (f is ArrayField arrayField) |
|||
{ |
|||
return arrayField.UpdateField(fieldId, n => n.Disable()); |
|||
} |
|||
|
|||
return f; |
|||
}); |
|||
} |
|||
|
|||
return schema.UpdateField(fieldId, f => f.Disable()); |
|||
} |
|||
|
|||
public static Schema UpdateField(this Schema schema, long fieldId, FieldProperties properties, long? parentId = null) |
|||
{ |
|||
if (parentId != null) |
|||
{ |
|||
return schema.UpdateField(parentId.Value, f => |
|||
{ |
|||
if (f is ArrayField arrayField) |
|||
{ |
|||
return arrayField.UpdateField(fieldId, n => n.Update(properties)); |
|||
} |
|||
|
|||
return f; |
|||
}); |
|||
} |
|||
|
|||
return schema.UpdateField(fieldId, f => f.Update(properties)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Newtonsoft.Json; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.Schemas.Json |
|||
{ |
|||
public sealed class JsonNestedFieldModel |
|||
{ |
|||
[JsonProperty] |
|||
public long Id { get; set; } |
|||
|
|||
[JsonProperty] |
|||
public string Name { get; set; } |
|||
|
|||
[JsonProperty] |
|||
public bool IsHidden { get; set; } |
|||
|
|||
[JsonProperty] |
|||
public bool IsDisabled { get; set; } |
|||
|
|||
[JsonProperty] |
|||
public FieldProperties Properties { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Squidex.Domain.Apps.Core.Schemas; |
|||
|
|||
namespace Squidex.Domain.Apps.Events.Schemas |
|||
{ |
|||
public sealed class SchemaCreatedNestedField |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public bool IsHidden { get; set; } |
|||
|
|||
public bool IsLocked { get; set; } |
|||
|
|||
public bool IsDisabled { get; set; } |
|||
|
|||
public FieldProperties Properties { get; set; } |
|||
} |
|||
} |
|||
Loading…
Reference in new issue