Skip to content

Commit

Permalink
Merge pull request #874 from cabinetoffice/feature/dp-804-registratio…
Browse files Browse the repository at this point in the history
…n-content-tweak

DP-804 - Make organisation name and address screens content conditional on org type
  • Loading branch information
andymantell authored Oct 30, 2024
2 parents 4b7306f + 45d6937 commit e2ec9a5
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 85 deletions.
6 changes: 3 additions & 3 deletions Frontend/CO.CDP.OrganisationApp.Tests/LocalizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public async Task OrganisationNamePage_DisplaysCorrectly_WhenLanguageIsDefaulted
responseBody.Should().NotBeNull();
response.StatusCode.Should().Be(HttpStatusCode.OK);

responseBody.Should().Contain("Enter the organisation's name");
responseBody.Should().Contain("Enter your organisation's name");
}

[Fact]
Expand All @@ -102,7 +102,7 @@ public async Task OrganisationNamePage_DisplaysCorrectly_WhenLanguageIsEnglish()
responseBody.Should().NotBeNull();
response.StatusCode.Should().Be(HttpStatusCode.OK);

responseBody.Should().Contain("Enter the organisation's name");
responseBody.Should().Contain("Enter your organisation's name");
}

[Fact]
Expand Down Expand Up @@ -142,7 +142,7 @@ public async Task OrganisationNamePage_DisplaysErrorMessageCorrectly_WhenLanguag
responseBody.Should().NotBeNull();
response.StatusCode.Should().Be(HttpStatusCode.OK);

responseBody.Should().Contain("<span class=\"field-validation-error\" data-valmsg-for=\"OrganisationName\" data-valmsg-replace=\"true\">Enter the organisation&#x27;s name</span>");
responseBody.Should().Contain("<span class=\"field-validation-error\" data-valmsg-for=\"OrganisationName\" data-valmsg-replace=\"true\">Enter your organisation&#x27;s name</span>");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@page "/organisation/{id}/name"
@model CO.CDP.OrganisationApp.Pages.Organisation.OrganisationNameModel
@using CO.CDP.OrganisationApp.WebApiClients
@using CO.CDP.Localization

@{
ViewData["Title"] = Html.DisplayNameFor(m => m.OrganisationName);
Expand All @@ -24,7 +26,16 @@
</label>
</h1>

<div id="hint" class="govuk-hint">As registered with Companies House if incorporated, or the trading name of the company</div>
<div id="hint" class="govuk-hint">
@if (Model.Organisation != null && (Model.Organisation.IsBuyer() || Model.Organisation.IsPendingBuyer()))
{
@Html.Raw(StaticTextResource.Organisation_EnterOrganisationName_Buyer_Hint)
}
else
{
@StaticTextResource.Organisation_EnterOrganisationName_Supplier_Hint
}
</div>

<div class="govuk-form-group @(organisationNameHasError ? "govuk-form-group--error" : "")">
@if (organisationNameHasError)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ public class OrganisationNameModel(IOrganisationClient organisationClient) : Pag

[BindProperty(SupportsGet = true)]
public Guid Id { get; set; }
public OrganisationWebApiClient.Organisation? Organisation;

public async Task<IActionResult> OnGet()
{
try
{
var organisation = await organisationClient.GetOrganisationAsync(Id);
if (organisation == null) return Redirect("/page-not-found");
Organisation = await organisationClient.GetOrganisationAsync(Id);
if (Organisation == null) return Redirect("/page-not-found");

OrganisationName = organisation.Name;
OrganisationName = Organisation.Name;

return Page();
}
Expand All @@ -45,9 +46,9 @@ public async Task<IActionResult> OnPost()
return Page();
}

var organisation = await organisationClient.GetOrganisationAsync(Id);
Organisation = await organisationClient.GetOrganisationAsync(Id);

if (organisation == null)
if (Organisation == null)
{
return Redirect("/page-not-found");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CO.CDP.OrganisationApp.Constants;
using CO.CDP.OrganisationApp.Models;
using CO.CDP.OrganisationApp.Pages.Shared;
using CO.CDP.OrganisationApp.WebApiClients;
using Microsoft.AspNetCore.Authorization;
Expand All @@ -24,15 +25,17 @@ public class OrganisationRegisteredAddressModel(OrganisationWebApiClient.IOrgani

[BindProperty]
public bool? RedirectToOverview { get; set; }
public OrganisationWebApiClient.Organisation? Organisation;

public async Task<IActionResult> OnGet()
{
SetupAddress(true);
Organisation = await organisationClient.GetOrganisationAsync(Id);

if (Organisation == null) return Redirect("/page-not-found");

var organisation = await organisationClient.GetOrganisationAsync(Id);
if (organisation == null) return Redirect("/page-not-found");
SetupAddress(true);

var regsiteredAddress = organisation.Addresses.FirstOrDefault(x => x.Type == AddressType.Registered);
var regsiteredAddress = Organisation.Addresses.FirstOrDefault(x => x.Type == AddressType.Registered);

if (regsiteredAddress == null) return Redirect("/page-not-found");

Expand All @@ -57,8 +60,6 @@ public async Task<IActionResult> OnPost()
}
try
{
var organisation = await organisationClient.GetOrganisationAsync(Id);

ICollection<OrganisationWebApiClient.OrganisationAddress> addresses = [
new OrganisationWebApiClient.OrganisationAddress(
streetAddress: Address.AddressLine1,
Expand Down Expand Up @@ -91,11 +92,24 @@ private void SetupAddress(bool reset = false)
{
if (reset) Address = new AddressPartialModel { UkOrNonUk = UkOrNonUk };

Address.Heading = Address.IsNonUkAddress ?
"Enter your organisation's registered non-UK address" : "Enter your organisation's registered address";

Address.AddressHint = Address.IsNonUkAddress ?
"The address recorded on public records or within the public domain" : "The address registered with Companies House, or the principal address the business conducts its activities. For example, a head office.";
if (Address.IsNonUkAddress)
{
Address.Heading = "Enter your organisation's registered non-UK address";
Address.AddressHint = "The address recorded on public records or within the public domain.";
}
else
{
if (Organisation != null && (Organisation.IsBuyer() || Organisation.IsPendingBuyer()))
{
Address.Heading = "Enter your organisation's address";
Address.AddressHint = "The principal address the organisation conducts its activities. For example, a head office.";
}
else
{
Address.Heading = "Enter your organisation's registered address";
Address.AddressHint = "The address registered with Companies House, or the principal address the business conducts its activities. For example, a head office.";
}
}

Address.NonUkAddressLink = $"/organisation/{Id}/address/non-uk{(RedirectToOverview == true ? "?frm-overview" : "")}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@
</label>
</h1>

<div id="hint" class="govuk-hint">@StaticTextResource.OrganisationRegistration_EnterOrganisationName_Hint</div>
<div id="hint" class="govuk-hint">
@if (Model.RegistrationDetails.OrganisationType == Constants.OrganisationType.Buyer)
{
@Html.Raw(StaticTextResource.Organisation_EnterOrganisationName_Buyer_Hint)
}
else
{
@StaticTextResource.Organisation_EnterOrganisationName_Supplier_Hint
}
</div>

<div class="govuk-form-group @(organisationNameHasError ? "govuk-form-group--error" : "")">
@if (organisationNameHasError)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,22 @@ private void SetupAddress(bool reset = false)
{
if (reset) Address = new AddressPartialModel { UkOrNonUk = UkOrNonUk };

Address.Heading = Address.IsNonUkAddress ?
"Enter the organisation's registered non-UK address" : "Enter the organisation's registered address";

Address.AddressHint = Address.IsNonUkAddress ?
"The address recorded on public records or within the public domain" : "The address registered with Companies House, or the principal address the business conducts its activities. For example, a head office.";
if (Address.IsNonUkAddress)
{
Address.Heading = "Enter your organisation's registered non-UK address";
Address.AddressHint = "The address recorded on public records or within the public domain.";
} else
{
if(RegistrationDetails.OrganisationType == OrganisationType.Buyer)
{
Address.Heading = "Enter your organisation's address";
Address.AddressHint = "The principal address the organisation conducts its activities. For example, a head office.";
} else
{
Address.Heading = "Enter your organisation's registered address";
Address.AddressHint = "The address registered with Companies House, or the principal address the business conducts its activities. For example, a head office.";
}
}

Address.NonUkAddressLink = $"/registration/organisation-registered-address/non-uk{(RedirectToSummary == true ? "?frm-summary" : "")}";
}
Expand Down
56 changes: 28 additions & 28 deletions Services/CO.CDP.Localization/StaticTextResource.cy.resx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -138,7 +138,7 @@
<data name="OrganisationRegistration_EnterOrganisationName_Heading" xml:space="preserve">
<value>Rhowch enw’r sefydliad</value>
</data>
<data name="OrganisationRegistration_EnterOrganisationName_Hint" xml:space="preserve">
<data name="Organisation_EnterOrganisationName_Supplier_Hint" xml:space="preserve">
<value>Fel y'i cofrestrwyd â Thŷ'r Cwmnïau os yw'n gorfforedig, neu enw masnachu'r cwmni.</value>
</data>
<data name="Global_Continue" xml:space="preserve">
Expand Down
65 changes: 34 additions & 31 deletions Services/CO.CDP.Localization/StaticTextResource.resx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -160,15 +160,18 @@
<value>{0} records</value>
</data>
<data name="OrganisationRegistration_EnterOrganisationName_Heading" xml:space="preserve">
<value>Enter the organisation's name</value>
<value>Enter your organisation's name</value>
</data>
<data name="Organisation_EnterOrganisationName_Buyer_Hint" xml:space="preserve">
<value>If you’re a department, agency or public body on the &lt;a class="govuk-link" target="_blank" href="https://www.gov.uk/government/organisations"&gt;GOV.UK organisations list (opens in a new tab)&lt;/a&gt;, use the exact name shown. If not, use your full official name. For example, HM Revenue &amp; Customs not HMRC.</value>
</data>
<data name="OrganisationRegistration_EnterOrganisationName_Hint" xml:space="preserve">
<value>As registered on Companies House if incorporated, or the trading name of the company</value>
<data name="Organisation_EnterOrganisationName_Supplier_Hint" xml:space="preserve">
<value>As registered on Companies House if incorporated, or the trading name of the company.</value>
</data>
<data name="Global_Error" xml:space="preserve">
<value>Error</value>
</data>
<data name="Global_Continue" xml:space="preserve">
<value>Continue</value>
</data>
</root>
</root>

0 comments on commit e2ec9a5

Please sign in to comment.