Skip to content

Commit 3778a7f

Browse files
Feature/label visibility default behaviour (#146)
* Allows word count validation for charctercount field * Added feature flag for showing field label when only one field * Update changelog and version
1 parent 59ce956 commit 3778a7f

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,12 @@ All notable changes to this service will be documented in this file.
5454

5555
## [1.2.10]
5656
### Notes
57-
- Added support custom application names per tenant.
57+
- Added support custom application names per tenant.
58+
59+
## [1.2.11]
60+
### Notes
61+
- Added max-words property to character count field.
62+
63+
## [1.2.12]
64+
### Notes
65+
- Added root level template property "hideFieldLabelWhenOnlyOneField" to toggle labels hiding for single field pages.

src/DfE.ExternalApplications.Domain/Models/FormTemplate.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ public class FormTemplate
3232
/// </summary>
3333
[JsonPropertyName("defaultFieldRequirementPolicy")]
3434
public string? DefaultFieldRequirementPolicy { get; set; }
35+
36+
[JsonPropertyName("hideFieldLabelWhenOnlyOneField")]
37+
public bool HideFieldLabelWhenOnlyOneField { get; set; } = true; // Default to true for backward compatibility
3538
}
3639
}

src/DfE.ExternalApplications.Web/DfE.ExternalApplications.Web.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<UserSecretsId>8051c984-585b-4a5e-b6d7-833e5dd4afe7</UserSecretsId>
8-
<Version>1.2.10</Version>
9-
<InformationalVersion>1.2.10</InformationalVersion>
8+
<Version>1.2.12</Version>
9+
<InformationalVersion>1.2.12</InformationalVersion>
1010
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
1111
</PropertyGroup>
1212

src/DfE.ExternalApplications.Web/Views/Shared/FormEngine/_FormPage.cshtml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
.FieldType.Equals("upload", StringComparison.OrdinalIgnoreCase));
1818

1919
string typeOfFirstField = Model.CurrentPage.Fields[0].Type;
20-
bool labelledByHeader = (Model.CurrentPage.Fields.Count == 1) && typeOfFirstField != "complexField";
20+
bool hideFieldLabel = Model.Template.HideFieldLabelWhenOnlyOneField
21+
&& Model.CurrentPage.Fields.Count == 1
22+
&& typeOfFirstField != "complexField";
23+
2124
bool hasAutocompleteField = Model.CurrentPage.Fields.Any(f =>
2225
f.Type == "complexField" &&
2326
f.ComplexField != null &&
@@ -130,7 +133,7 @@
130133
var fieldModelState = ViewData.ModelState.Where(f => f.Key == field.FieldId).FirstOrDefault();
131134
var errorMessage = fieldModelState.Value?.Errors?.FirstOrDefault()?.ErrorMessage ?? String.Empty;
132135

133-
if (labelledByHeader)
136+
if (hideFieldLabel)
134137
{
135138
field.Label.IsVisible = false;
136139
}

0 commit comments

Comments
 (0)