From ea3254018aa14cd41a79fbc92a058b0954e335ee Mon Sep 17 00:00:00 2001
From: Russell Thorn <1692222+russellthorn@users.noreply.github.com>
Date: Fri, 22 Mar 2024 14:12:48 +0000
Subject: [PATCH 1/7] pushing to branch for collabing
---
.../editLiabilityDatesLiable.scala.html | 101 +++-
.../periodDatesLiable.scala.html | 107 +++--
.../periodInReliefDates.scala.html | 109 +++--
app/views/reliefs/chooseReliefs.scala.html | 452 ++++++++++++++----
conf/messages | 69 ++-
5 files changed, 653 insertions(+), 185 deletions(-)
diff --git a/app/views/editLiability/editLiabilityDatesLiable.scala.html b/app/views/editLiability/editLiabilityDatesLiable.scala.html
index af9cfbb5..266b65b4 100644
--- a/app/views/editLiability/editLiabilityDatesLiable.scala.html
+++ b/app/views/editLiability/editLiabilityDatesLiable.scala.html
@@ -75,30 +75,85 @@
@formHelper(action = controllers.editLiability.routes.EditLiabilityDatesLiableController.save(formBundleNo, periodKey)) {
+
- @govukDateInput(DateInput(
- hint = Some(Hint(
- content = Text(messages("ated.property-details-period.datesLiable.startDate.hint", periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))))
- )),
- fieldset = Some(Fieldset(
- legend = Some(Legend(
- content = Text(messages("ated.property-details-period.change-dates-liable.startDate"))
- ))
- )),
- items = dateItems
- ).withFormField(propertyDetailsForm("startDate")))
-
- @govukDateInput(DateInput(
- hint = Some(Hint(
- content = Text(messages("ated.property-details-period.datesLiable.endDate.hint", periodEndDate(periodKey).toString(messages("ated.date-format.numeric"))))
- )),
- fieldset = Some(Fieldset(
- legend = Some(Legend(
- content = Text(messages("ated.property-details-period.change-dates-liable.endDate"))
- ))
- )),
- items = dateItems
- ).withFormField(propertyDetailsForm("endDate")))
+
@govukButton(Button(
content = Text(messages("ated.save-and-continue")),
diff --git a/app/views/propertyDetails/periodDatesLiable.scala.html b/app/views/propertyDetails/periodDatesLiable.scala.html
index 6de1c9cd..76686376 100644
--- a/app/views/propertyDetails/periodDatesLiable.scala.html
+++ b/app/views/propertyDetails/periodDatesLiable.scala.html
@@ -74,34 +74,85 @@
@formHelper(action=controllers.propertyDetails.routes.PeriodDatesLiableController.save(id, periodKey, mode)) {
-
- @govukDateInput(DateInput(
- hint = Some(Hint(
- content = Text(messages("ated.property-details-period.datesInRelief.startDate.hint",
- PeriodUtils.periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))))
- )),
- fieldset = Some(Fieldset(
- legend = Some(Legend(
- content = Text(messages("ated.property-details-period.datesLiable.startDate")),
- classes = "govuk-label--s"
- ))
- )),
- items = dateItems
- ).withFormField(propertyDetailsForm("startDate")))
-
- @govukDateInput(DateInput(
- hint = Some(Hint(
- content = Text(messages("ated.property-details-period.datesInRelief.endDate.hint",
- PeriodUtils.periodEndDate(periodKey).toString(messages("ated.date-format.numeric"))))
- )),
- fieldset = Some(Fieldset(
- legend = Some(Legend(
- content = Text(messages("ated.property-details-period.datesLiable.endDate")),
- classes = "govuk-label--s"
- ))
- )),
- items = dateItems
- ).withFormField(propertyDetailsForm("endDate")))
+
+
+
@govukButton(Button(
content = Text(messages("ated.save-and-continue")),
diff --git a/app/views/propertyDetails/periodInReliefDates.scala.html b/app/views/propertyDetails/periodInReliefDates.scala.html
index 22ca8aaa..c6da33c5 100644
--- a/app/views/propertyDetails/periodInReliefDates.scala.html
+++ b/app/views/propertyDetails/periodInReliefDates.scala.html
@@ -59,7 +59,7 @@
@backLinkHtml
@if(propertyDetailsForm.errors.nonEmpty) {
- @govukErrorSummary(ErrorSummary().withFormErrorsAsText(propertyDetailsForm, mapping = Map("startDate" -> "startDate.day", "endDate" -> "endDate.day")))
+ @govukErrorSummary(ErrorSummary().withFormErrorsAsText(propertyDetailsForm, mapping = Map("startDate" -> ".", "endDate" -> "endDate.day")))
}
@formHelper(action=controllers.propertyDetails.routes.PeriodDatesLiableController.save(id, periodKey, mode)) {
-
-
+ @dualDateInputs(
+ fields = ("startDate", "endDate"),
+ legends = ("ated.property-details-period.datesLiable.startDate", "ated.property-details-period.datesLiable.endDate"),
+ hints = ("ated.property-details-period.datesInRelief.startDate.hint", "ated.property-details-period.datesInRelief.endDate.hint"),
+ dayHidden = ("ated.property-details-period.datesLiable.startDate.hiddenContentDay", "ated.property-details-period.datesLiable.endDate.hiddenContentDay"),
+ monthHidden = ("ated.property-details-period.datesLiable.startDate.hiddenContentMonth", "ated.property-details-period.datesLiable.endDate.hiddenContentMonth"),
+ yearHidden = ("ated.property-details-period.datesLiable.startDate.hiddenContentYear", "ated.property-details-period.datesLiable.endDate.hiddenContentYear"),
+ periodKey = periodKey,
+ form = propertyDetailsForm
+ )
@govukButton(Button(
content = Text(messages("ated.save-and-continue")),
From c87ec6d5a32807b356e156fc5af1f1e8090f3484 Mon Sep 17 00:00:00 2001
From: Ben Ryan <37295698+benryan1790@users.noreply.github.com>
Date: Tue, 2 Apr 2024 13:32:31 +0100
Subject: [PATCH 3/7] dateInput component updated, can be used for single date
inputs
---
app/views/helpers/dateInput.scala.html | 111 +++++++++++++
app/views/helpers/dualDateInputs.scala.html | 152 ------------------
.../periodDatesLiable.scala.html | 25 ++-
3 files changed, 129 insertions(+), 159 deletions(-)
create mode 100644 app/views/helpers/dateInput.scala.html
delete mode 100644 app/views/helpers/dualDateInputs.scala.html
diff --git a/app/views/helpers/dateInput.scala.html b/app/views/helpers/dateInput.scala.html
new file mode 100644
index 00000000..c019e77e
--- /dev/null
+++ b/app/views/helpers/dateInput.scala.html
@@ -0,0 +1,111 @@
+@*
+ * Copyright 2024 HM Revenue & Customs
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *@
+
+@import _root_.utils._
+@import models.StringFormatting._
+@import play.twirl.api.HtmlFormat
+
+@(
+ field: String,
+ legend: String,
+ hint: String,
+ dayHidden: String,
+ monthHidden: String,
+ yearHidden: String,
+ periodKey: Int,
+ form: Form[_])(implicit messages: Messages)
+
+@formGroupErrorClass(field: String) = @{
+ if(form.errors.exists(_.key.contains(field))) {
+ "govuk-form-group govuk-form-group--error"
+ } else {
+ "govuk-form-group"
+ }
+}
+
+@fieldLevelErrorClass(field: String, dateField: String) = @{
+ val num = if(dateField == "year") "4" else "2"
+ if(form.errors.exists(er => er.key == field || (er.key.startsWith(field) && er.message.toLowerCase.contains(dateField)))) {
+ s"govuk-input govuk-date-input__input govuk-input--width-$num govuk-input--error"
+ } else {
+ s"govuk-input govuk-date-input__input govuk-input--width-$num"
+ }
+}
+
+@fieldLevelErrorMessage(field: String) = @{
+ val message = form.errors.collect {
+ case e if e.key.startsWith(field) =>
+ e.format
+ }
+
+ if(message.nonEmpty) {
+ Html(
+ s"""
+ | Error: ${message.head}
+ |
""".stripMargin
+ )
+ } else HtmlFormat.empty
+}
+
+@fieldValue(field: String) = @{
+ form(field).value.map(x => s"value=$x")
+}
+
+@id(field: String, dateField: String) = @{
+ s"$field.$dateField"
+}
+
+
diff --git a/app/views/helpers/dualDateInputs.scala.html b/app/views/helpers/dualDateInputs.scala.html
deleted file mode 100644
index b94ccc15..00000000
--- a/app/views/helpers/dualDateInputs.scala.html
+++ /dev/null
@@ -1,152 +0,0 @@
-@*
- * Copyright 2024 HM Revenue & Customs
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *@
-
-@import _root_.utils._
-@import models.StringFormatting._
-@import play.twirl.api.HtmlFormat
-
-@(
- fields: (String, String),
- legends: (String, String),
- hints: (String, String),
- dayHidden: (String, String),
- monthHidden: (String, String),
- yearHidden: (String, String),
- periodKey: Int,
- form: Form[_])(implicit messages: Messages)
-
-@formGroupErrorClass(field: String) = @{
- if(form.errors.exists(_.key.contains(field))) {
- "govuk-form-group govuk-form-group--error"
- } else {
- "govuk-form-group"
- }
-}
-
-@fieldLevelErrorClass(field: String, dateField: String) = @{
- val num = if(dateField == "year") "4" else "2"
- if(form.errors.exists(er => er.key == field || (er.key.startsWith(field) && er.message.toLowerCase.contains(dateField)))) {
- s"govuk-input govuk-date-input__input govuk-input--width-$num govuk-input--error"
- } else {
- s"govuk-input govuk-date-input__input govuk-input--width-$num"
- }
-}
-
-@fieldLevelErrorMessage(field: String) = @{
- val message = form.errors.collect {
- case e if e.key.startsWith(field) =>
- e.format
- }
-
- if(message.nonEmpty) {
- Html(
- s"""
- | Error: ${message.head}
- |
""".stripMargin
- )
- } else HtmlFormat.empty
-}
-
-@fieldValue(field: String) = @{
- form(field).value.map(x => s"value=$x")
-}
-
-@id(field: String, dateField: String) = @{
- s"$field.$dateField"
-}
-
-
-
-
\ No newline at end of file
diff --git a/app/views/propertyDetails/periodDatesLiable.scala.html b/app/views/propertyDetails/periodDatesLiable.scala.html
index bd2cad4b..caca97a8 100644
--- a/app/views/propertyDetails/periodDatesLiable.scala.html
+++ b/app/views/propertyDetails/periodDatesLiable.scala.html
@@ -66,13 +66,24 @@
@formHelper(action=controllers.propertyDetails.routes.PeriodDatesLiableController.save(id, periodKey, mode)) {
- @dualDateInputs(
- fields = ("startDate", "endDate"),
- legends = ("ated.property-details-period.datesLiable.startDate", "ated.property-details-period.datesLiable.endDate"),
- hints = ("ated.property-details-period.datesInRelief.startDate.hint", "ated.property-details-period.datesInRelief.endDate.hint"),
- dayHidden = ("ated.property-details-period.datesLiable.startDate.hiddenContentDay", "ated.property-details-period.datesLiable.endDate.hiddenContentDay"),
- monthHidden = ("ated.property-details-period.datesLiable.startDate.hiddenContentMonth", "ated.property-details-period.datesLiable.endDate.hiddenContentMonth"),
- yearHidden = ("ated.property-details-period.datesLiable.startDate.hiddenContentYear", "ated.property-details-period.datesLiable.endDate.hiddenContentYear"),
+ @dateInput(
+ field = "startDate",
+ legend = "ated.property-details-period.datesLiable.startDate",
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.property-details-period.datesLiable.startDate.hiddenContentDay",
+ monthHidden = "ated.property-details-period.datesLiable.startDate.hiddenContentMonth",
+ yearHidden = "ated.property-details-period.datesLiable.startDate.hiddenContentYear",
+ periodKey = periodKey,
+ form = propertyDetailsForm
+ )
+
+ @dateInput(
+ field = "endDate",
+ legend = "ated.property-details-period.datesLiable.endDate",
+ hint = "ated.property-details-period.datesInRelief.endDate.hint",
+ dayHidden = "ated.property-details-period.datesLiable.endDate.hiddenContentDay",
+ monthHidden = "ated.property-details-period.datesLiable.endDate.hiddenContentMonth",
+ yearHidden = "ated.property-details-period.datesLiable.endDate.hiddenContentYear",
periodKey = periodKey,
form = propertyDetailsForm
)
From 89fd67e7632d310823aa907f45ba8ff2f9ee1a10 Mon Sep 17 00:00:00 2001
From: Russell Thorn <1692222+russellthorn@users.noreply.github.com>
Date: Wed, 24 Apr 2024 10:47:44 +0100
Subject: [PATCH 4/7] Temp commit to push changes so I can check branch against
main
---
.../periodInReliefDates.scala.html | 109 +---
app/views/reliefs/chooseReliefs.scala.html | 494 +++++-------------
.../periodDatesLiableSpec.scala | 8 +-
.../periodInReliefDatesSpec.scala | 6 +-
4 files changed, 164 insertions(+), 453 deletions(-)
diff --git a/app/views/propertyDetails/periodInReliefDates.scala.html b/app/views/propertyDetails/periodInReliefDates.scala.html
index c6da33c5..85cb1001 100644
--- a/app/views/propertyDetails/periodInReliefDates.scala.html
+++ b/app/views/propertyDetails/periodInReliefDates.scala.html
@@ -45,21 +45,13 @@
}
}
-@dateItems = @{
- Seq(InputItem(attributes = Map("maxLength" -> "2")),
- InputItem(attributes = Map("maxLength" -> "2")),
- InputItem(attributes = Map("maxLength" -> "4"))
- )
-}
-
-
@newMain(title = titleBuilder(messages("ated.property-details-period.datesInRelief.title"), Some(propertyDetailsForm)),
serviceInfoContent = serviceInfoContent) {
@backLinkHtml
@if(propertyDetailsForm.errors.nonEmpty) {
- @govukErrorSummary(ErrorSummary().withFormErrorsAsText(propertyDetailsForm, mapping = Map("startDate" -> ".", "endDate" -> "endDate.day")))
+ @govukErrorSummary(ErrorSummary().withFormErrorsAsText(propertyDetailsForm, mapping = Map("startDate" -> "startDate.day", "endDate" -> "endDate.day")))
}
@@ -76,85 +68,28 @@
@formHelper(action=controllers.propertyDetails.routes.PeriodInReliefDatesController.save(id, periodKey)) {
-
-
+ @dateInput(
+ field = "startDate",
+ legend = "ated.property-details-period.datesInRelief.startDate",
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.property-details-period.datesInRelief.startDate.hiddenContentDay",
+ monthHidden = "ated.property-details-period.datesInRelief.startDate.hiddenContentMonth",
+ yearHidden = "ated.property-details-period.datesInRelief.startDate.hiddenContentYear",
+ periodKey = periodKey,
+ form = propertyDetailsForm
+ )
+
+ @dateInput(
+ field = "endDate",
+ legend = "ated.property-details-period.datesInRelief.endDate",
+ hint = "ated.property-details-period.datesInRelief.endDate.hint",
+ dayHidden = "ated.property-details-period.datesInRelief.endDate.hiddenContentDay",
+ monthHidden = "ated.property-details-period.datesInRelief.endDate.hiddenContentMonth",
+ yearHidden = "ated.property-details-period.datesInRelief.endDate.hiddenContentYear",
+ periodKey = periodKey,
+ form = propertyDetailsForm
+ )
@govukButton(Button(
content = Text(messages("ated.save-and-continue")),
diff --git a/app/views/reliefs/chooseReliefs.scala.html b/app/views/reliefs/chooseReliefs.scala.html
index 90bc723f..2dc15852 100644
--- a/app/views/reliefs/chooseReliefs.scala.html
+++ b/app/views/reliefs/chooseReliefs.scala.html
@@ -82,392 +82,168 @@
}
}
-@inputItems = @{
- Seq(InputItem(attributes = Map("maxLength" -> "2")),
- InputItem(attributes = Map("maxLength" -> "2")),
- InputItem(attributes = Map("maxLength" -> "4"))
- )
+@rentalBusinessDateLegend = @{
+ messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.rentalBusiness"))
}
-@rentalBusinessDateConditional = {
-
+@openToPublicDateLegend = @{
+ messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.openToPublic"))
+}
+
+@propertyDeveloperDateLegend = @{
+ messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.propertyDeveloper"))
+}
+
+@propertyTradingDateLegend = @{
+ messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.propertyTrading"))
+}
+
+@lendingDateLegend = @{
+ messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.lending"))
+}
+
+@employeeOccupationDateLegend = @{
+ messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.employeeOccupation"))
+}
+
+@farmHousesDateLegend = @{
+ messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.farmHouses"))
+}
+
+@equityReleaseDateLegend = @{
+ messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.equityRelease"))
+}
+@socialHousingDateLegend = @{
+ messages("ated.choose-reliefs.date", messages(chooseSingleReliefsocialHousingMessage))
+}
+
+@rentalBusinessDateConditional = {
+ @dateInput(
+ field = "rentalBusinessDate",
+ legend = rentalBusinessDateLegend,
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.choose-single-relief.rentalBusiness.hiddenContentDay",
+ monthHidden = "ated.choose-single-relief.rentalBusiness.hiddenContentMonth",
+ yearHidden = "ated.choose-single-relief.rentalBusiness.hiddenContentYear",
+ periodKey = periodKey,
+ form = reliefsForm
+ )
}
@openToPublicDateConditional = {
-
+ @dateInput(
+ field = "openToPublicDate",
+ legend = openToPublicDateLegend,
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.choose-single-relief.openToPublic.hiddenContentDay",
+ monthHidden = "ated.choose-single-relief.openToPublic.hiddenContentMonth",
+ yearHidden = "ated.choose-single-relief.openToPublic.hiddenContentYear",
+ periodKey = periodKey,
+ form = reliefsForm
+ )
}
+
@propertyDeveloperDateConditional = {
-
+ @dateInput(
+ field = "propertyDeveloperDate",
+ legend = propertyDeveloperDateLegend,
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.choose-single-relief.propertyDeveloper.hiddenContentDay",
+ monthHidden = "ated.choose-single-relief.propertyDeveloper.hiddenContentMonth",
+ yearHidden = "ated.choose-single-relief.propertyDeveloper.hiddenContentYear",
+ periodKey = periodKey,
+ form = reliefsForm
+ )
}
@propertyTradingDateConditional = {
-
-
+ @dateInput(
+ field = "propertyTradingDate",
+ legend = propertyTradingDateLegend,
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.choose-single-relief.propertyTrading.hiddenContentDay",
+ monthHidden = "ated.choose-single-relief.propertyTrading.hiddenContentMonth",
+ yearHidden = "ated.choose-single-relief.propertyTrading.hiddenContentYear",
+ periodKey = periodKey,
+ form = reliefsForm
+ )
}
@lendingDateConditional = {
-
+ @dateInput(
+ field = "lendingDate",
+ legend = lendingDateLegend,
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.choose-single-relief.lending.hiddenContentDay",
+ monthHidden = "ated.choose-single-relief.lending.hiddenContentMonth",
+ yearHidden = "ated.choose-single-relief.lending.hiddenContentYear",
+ periodKey = periodKey,
+ form = reliefsForm
+ )
}
@employeeOccupationDateConditional = {
-
+ @dateInput(
+ field = "employeeOccupationDate",
+ legend = employeeOccupationDateLegend,
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.choose-single-relief.employeeOccupation.hiddenContentDay",
+ monthHidden = "ated.choose-single-relief.employeeOccupation.hiddenContentMonth",
+ yearHidden = "ated.choose-single-relief.employeeOccupation.hiddenContentYear",
+ periodKey = periodKey,
+ form = reliefsForm
+ )
}
@farmHousesDateConditional = {
-
+ @dateInput(
+ field = "farmHousesDate",
+ legend = farmHousesDateLegend,
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.choose-single-relief.farmHouses.hiddenContentDay",
+ monthHidden = "ated.choose-single-relief.farmHouses.hiddenContentMonth",
+ yearHidden = "ated.choose-single-relief.farmHouses.hiddenContentYear",
+ periodKey = periodKey,
+ form = reliefsForm
+ )
}
-@socialHousingDateConditional = {
-
+@socialHousingDateDay = @{
+ messages("ated.choose-reliefs.dates", messages("ated.choose-reliefs.dates.day"), messages(chooseSingleReliefsocialHousingMessage))
+}
+@socialHousingDateMonth = @{
+ messages("ated.choose-reliefs.dates", messages("ated.choose-reliefs.dates.month"), messages(chooseSingleReliefsocialHousingMessage))
+}
+@socialHousingDateYear = @{
+ messages("ated.choose-reliefs.dates", messages("ated.choose-reliefs.dates.year"), messages(chooseSingleReliefsocialHousingMessage))
+}
+@socialHousingDateConditional = {
+ @dateInput(
+ field = "socialHousingDate",
+ legend = socialHousingDateLegend,
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = socialHousingDateDay,
+ monthHidden = socialHousingDateMonth,
+ yearHidden = socialHousingDateYear,
+ periodKey = periodKey,
+ form = reliefsForm
+ )
}
@equityReleaseDateConditional = {
-
+ @dateInput(
+ field = "equityReleaseDate",
+ legend = equityReleaseDateLegend,
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.choose-single-relief.equityRelease.hiddenContentDay",
+ monthHidden = "ated.choose-single-relief.equityRelease.hiddenContentMonth",
+ yearHidden = "ated.choose-single-relief.equityRelease.hiddenContentYear",
+ periodKey = periodKey,
+ form = reliefsForm
+ )
}
@newMain(title = titleBuilder(messages("ated.choose-reliefs.title"), Some(amendedForm)),
diff --git a/test/views/propertyDetails/periodDatesLiableSpec.scala b/test/views/propertyDetails/periodDatesLiableSpec.scala
index b333baa8..d888cdbf 100644
--- a/test/views/propertyDetails/periodDatesLiableSpec.scala
+++ b/test/views/propertyDetails/periodDatesLiableSpec.scala
@@ -66,9 +66,9 @@ Feature("The user can add a period that the property is liable") {
Then("The date fields should have the correct titles")
assert(document.getElementsByTag("legend")
- .text contains "What was the start date in this chargeable period when the property became liable for a charge?")
+ .text contains "What was the start date when the property became liable for a charge during this period?")
assert(document.getElementsByTag("legend")
- .text contains "What was the end date in this chargeable period when the property stopped being liable for a charge?")
+ .text contains "What was the end date the property stopped being liable for a charge during this period?")
Then("The date fields should have the correct default values")
assert(document.getElementById("startDate.day").attr("value") === "")
@@ -106,9 +106,9 @@ Feature("The user can add a period that the property is liable") {
Then("The date fields should have the correct titles")
assert(document.getElementsByTag("legend")
- .text contains "What was the start date in this chargeable period when the property became liable for a charge?")
+ .text contains "What was the start date when the property became liable for a charge during this period?")
assert(document.getElementsByTag("legend")
- .text contains "What was the end date in this chargeable period when the property stopped being liable for a charge?")
+ .text contains "What was the end date the property stopped being liable for a charge during this period?")
Then("The date fields should have the correct default values")
assert(document.getElementById("startDate.day").attr("value") === "")
diff --git a/test/views/propertyDetails/periodInReliefDatesSpec.scala b/test/views/propertyDetails/periodInReliefDatesSpec.scala
index 2689d989..8377dba9 100644
--- a/test/views/propertyDetails/periodInReliefDatesSpec.scala
+++ b/test/views/propertyDetails/periodInReliefDatesSpec.scala
@@ -63,10 +63,10 @@ Feature("The user can add a period that the property is in relief") {
Then("The date fields should have the correct titles and hints")
assert(document.getElementById("startDate-hint").text === "For example, 1 4 2015")
assert(document.getElementsByClass("govuk-fieldset__legend").text
- contains "What was the start date in this current period, when the relief started?")
+ contains "What was the start date of the relief in this current period?")
assert(document.getElementsByClass("govuk-fieldset__legend").text
- contains "What was the end date in this current period, when the relief ended?")
- assert(document.getElementById("endDate-hint").text === "For example, 31 3 2016")
+ contains "What was the end date of the relief in this current period?")
+ assert(document.getElementById("endDate-hint").text === "For example, 1 4 2015")
Then("The date fields should have the correct default values")
assert(document.getElementById("startDate.day").attr("value") === "")
From 517012e30f7035ae19e4b99e7207911b60a365e8 Mon Sep 17 00:00:00 2001
From: Russell Thorn <1692222+russellthorn@users.noreply.github.com>
Date: Mon, 13 May 2024 09:39:37 +0100
Subject: [PATCH 5/7] Updating editLiabilityDatesLiable to use new date
component
Also updating the date component so it adds aria-describedby to the fieldset that points to the error message id.
Updated tests inline with changes
---
.../editLiabilityDatesLiable.scala.html | 100 ++++--------------
app/views/helpers/dateInput.scala.html | 10 +-
.../editLiabilityDatesLiableSpec.scala | 22 ++--
3 files changed, 42 insertions(+), 90 deletions(-)
diff --git a/app/views/editLiability/editLiabilityDatesLiable.scala.html b/app/views/editLiability/editLiabilityDatesLiable.scala.html
index 266b65b4..60e6a680 100644
--- a/app/views/editLiability/editLiabilityDatesLiable.scala.html
+++ b/app/views/editLiability/editLiabilityDatesLiable.scala.html
@@ -19,6 +19,7 @@
@import models._
@import play.twirl.api.HtmlFormat
@import uk.gov.hmrc.govukfrontend.views.html.components._
+@import views.html.helpers._
@import views.ViewUtils.titleBuilder
@import models.StringFormatting._
@@ -75,85 +76,28 @@
@formHelper(action = controllers.editLiability.routes.EditLiabilityDatesLiableController.save(formBundleNo, periodKey)) {
-
-
+ @dateInput(
+ field = "startDate",
+ legend = "ated.property-details-period.change-dates-liable.startDate",
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.property-details-period.change-dates-liable.startDate.hiddenContentDay",
+ monthHidden = "ated.property-details-period.change-dates-liable.startDate.hiddenContentMonth",
+ yearHidden = "ated.property-details-period.change-dates-liable.startDate.hiddenContentYear",
+ periodKey = periodKey,
+ form = propertyDetailsForm
+ )
+
+ @dateInput(
+ field = "endDate",
+ legend = "ated.property-details-period.change-dates-liable.endDate",
+ hint = "ated.property-details-period.datesInRelief.startDate.hint",
+ dayHidden = "ated.property-details-period.change-dates-liable.endDate.hiddenContentDay",
+ monthHidden = "ated.property-details-period.change-dates-liable.endDate.hiddenContentMonth",
+ yearHidden = "ated.property-details-period.change-dates-liable.endDate.hiddenContentYear",
+ periodKey = periodKey,
+ form = propertyDetailsForm
+ )
@govukButton(Button(
content = Text(messages("ated.save-and-continue")),
diff --git a/app/views/helpers/dateInput.scala.html b/app/views/helpers/dateInput.scala.html
index c019e77e..00c83dae 100644
--- a/app/views/helpers/dateInput.scala.html
+++ b/app/views/helpers/dateInput.scala.html
@@ -60,6 +60,14 @@
} else HtmlFormat.empty
}
+
+@ariaDescribedby(field: String) = @{
+ form.error(field) match {
+ case Some(_) => s"$field-hint $field-error"
+ case _ => s"$field-hint"
+ }
+}
+
@fieldValue(field: String) = @{
form(field).value.map(x => s"value=$x")
}
@@ -69,7 +77,7 @@
}