-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EYQB-491: initial commit of the divider and hint text logic (#298)
* EYQB-491: initial commit of the divider and hint text logic * Added unit tests for the converter * Updated to add in hint text rendering to other places radio buttons are used and updated the existing e2e tests to ensure hint and dividers are covered * Removed commented code
- Loading branch information
Showing
20 changed files
with
245 additions
and
51 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/Dfe.EarlyYearsQualification.Content/Converters/OptionItemConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Dfe.EarlyYearsQualification.Content.Entities; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Dfe.EarlyYearsQualification.Content.Converters; | ||
|
||
public class OptionItemConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(IOptionItem); | ||
} | ||
|
||
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) | ||
{ | ||
var jo = JObject.Load(reader); | ||
var hasLabel = jo.ContainsKey("label") || jo.ContainsKey("Label"); | ||
IOptionItem model = hasLabel ? new Option() : new Divider(); | ||
serializer.Populate(jo.CreateReader(), model); | ||
return model; | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Dfe.EarlyYearsQualification.Content.Entities; | ||
|
||
public class Divider : IOptionItem | ||
{ | ||
public string Text { get; init; } = string.Empty; | ||
} |
3 changes: 3 additions & 0 deletions
3
src/Dfe.EarlyYearsQualification.Content/Entities/IOptionItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace Dfe.EarlyYearsQualification.Content.Entities; | ||
|
||
public interface IOptionItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
namespace Dfe.EarlyYearsQualification.Content.Entities; | ||
|
||
public class Option | ||
public class Option : IOptionItem | ||
{ | ||
public string Label { get; init; } = string.Empty; | ||
|
||
public string Value { get; init; } = string.Empty; | ||
|
||
public string Hint { get; init; } = string.Empty; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/Dfe.EarlyYearsQualification.Web/Models/Content/QuestionModels/DividerModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Dfe.EarlyYearsQualification.Web.Models.Content.QuestionModels; | ||
|
||
public class DividerModel : IOptionItemModel | ||
{ | ||
public string Text { get; set; } = string.Empty; | ||
} |
3 changes: 3 additions & 0 deletions
3
src/Dfe.EarlyYearsQualification.Web/Models/Content/QuestionModels/IOptionItemModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace Dfe.EarlyYearsQualification.Web.Models.Content.QuestionModels; | ||
|
||
public interface IOptionItemModel; |
4 changes: 3 additions & 1 deletion
4
src/Dfe.EarlyYearsQualification.Web/Models/Content/QuestionModels/OptionModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
namespace Dfe.EarlyYearsQualification.Web.Models.Content.QuestionModels; | ||
|
||
public class OptionModel | ||
public class OptionModel : IOptionItemModel | ||
{ | ||
public string Label { get; init; } = string.Empty; | ||
|
||
public string Value { get; init; } = string.Empty; | ||
|
||
public string Hint { get; init; } = string.Empty; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.