|
|
|
@ -38,7 +38,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards |
|
|
|
|
|
|
|
if (command.ParentFieldId.HasValue) |
|
|
|
{ |
|
|
|
var arrayField = GuardHelper.GetArrayFieldOrThrow(schema, command.ParentFieldId.Value); |
|
|
|
var arrayField = GuardHelper.GetArrayFieldOrThrow(schema, command.ParentFieldId.Value, false); |
|
|
|
|
|
|
|
if (arrayField.FieldsByName.ContainsKey(command.Name)) |
|
|
|
{ |
|
|
|
@ -64,12 +64,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards |
|
|
|
{ |
|
|
|
Guard.NotNull(command, nameof(command)); |
|
|
|
|
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId); |
|
|
|
|
|
|
|
if (field.IsLocked) |
|
|
|
{ |
|
|
|
throw new DomainException("Schema field is already locked."); |
|
|
|
} |
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); |
|
|
|
|
|
|
|
Validate.It(() => "Cannot update field.", e => |
|
|
|
{ |
|
|
|
@ -90,12 +85,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards |
|
|
|
{ |
|
|
|
Guard.NotNull(command, nameof(command)); |
|
|
|
|
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId); |
|
|
|
|
|
|
|
if (field.IsLocked) |
|
|
|
{ |
|
|
|
throw new DomainException("Schema field is locked."); |
|
|
|
} |
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); |
|
|
|
|
|
|
|
if (field.IsHidden) |
|
|
|
{ |
|
|
|
@ -108,11 +98,23 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void CanShow(Schema schema, ShowField command) |
|
|
|
{ |
|
|
|
Guard.NotNull(command, nameof(command)); |
|
|
|
|
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); |
|
|
|
|
|
|
|
if (!field.IsHidden) |
|
|
|
{ |
|
|
|
throw new DomainException("Schema field is already visible."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void CanDisable(Schema schema, DisableField command) |
|
|
|
{ |
|
|
|
Guard.NotNull(command, nameof(command)); |
|
|
|
|
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId); |
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); |
|
|
|
|
|
|
|
if (field.IsDisabled) |
|
|
|
{ |
|
|
|
@ -129,7 +131,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards |
|
|
|
{ |
|
|
|
Guard.NotNull(command, nameof(command)); |
|
|
|
|
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId); |
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); |
|
|
|
|
|
|
|
if (field.IsLocked) |
|
|
|
{ |
|
|
|
@ -137,23 +139,11 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void CanShow(Schema schema, ShowField command) |
|
|
|
{ |
|
|
|
Guard.NotNull(command, nameof(command)); |
|
|
|
|
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId); |
|
|
|
|
|
|
|
if (!field.IsHidden) |
|
|
|
{ |
|
|
|
throw new DomainException("Schema field is already visible."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void CanEnable(Schema schema, EnableField command) |
|
|
|
{ |
|
|
|
Guard.NotNull(command, nameof(command)); |
|
|
|
|
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId); |
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); |
|
|
|
|
|
|
|
if (!field.IsDisabled) |
|
|
|
{ |
|
|
|
@ -165,7 +155,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards |
|
|
|
{ |
|
|
|
Guard.NotNull(command, nameof(command)); |
|
|
|
|
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId); |
|
|
|
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); |
|
|
|
|
|
|
|
if (field.IsLocked) |
|
|
|
{ |
|
|
|
|