Skip to content

Commit

Permalink
Mark some data as ReadOnly in APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
iJungleboy committed Nov 22, 2021
1 parent 85396e3 commit bed83e0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
8 changes: 7 additions & 1 deletion ToSic.Eav.WebApi/Dto/ContentTypeDto.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using ToSic.Eav.WebApi.Security;

namespace ToSic.Eav.WebApi.Dto
{
public class ContentTypeDto: IdNameDto
public class ContentTypeDto: IdNameDto, IReadOnlyDto
{
public string Label { get; set; }
public string StaticName { get; set; }
Expand All @@ -17,5 +18,10 @@ public class ContentTypeDto: IdNameDto
public IDictionary<string, object> Properties { get; set; }

public HasPermissionsDto Permissions { get; set; }

//[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public bool? IsReadOnly { get; set; }

public string IsReadOnlyReason { get; set; }
}
}
5 changes: 4 additions & 1 deletion ToSic.Eav.WebApi/Dto/ContentTypeFieldDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace ToSic.Eav.WebApi.Dto
{
public class ContentTypeFieldDto
public class ContentTypeFieldDto: IReadOnlyDto
{
public int Id { get; set; }
public int SortOrder { get; set; }
Expand Down Expand Up @@ -34,5 +34,8 @@ public class ContentTypeFieldDto
/// New in v12.01
/// </remarks>
public bool HasFormulas { get; set; }

public bool? IsReadOnly { get; set; }
public string IsReadOnlyReason { get; set; }
}
}
16 changes: 16 additions & 0 deletions ToSic.Eav.WebApi/Dto/IReadOnlyDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;

namespace ToSic.Eav.WebApi.Dto
{
/// <summary>
/// Extends common DTOs to inform about it being read-only, and why
/// </summary>
public interface IReadOnlyDto
{
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
bool? IsReadOnly { get; set; }

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
string IsReadOnlyReason { get; set; }
}
}

0 comments on commit bed83e0

Please sign in to comment.