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)) { +
+
+ + @messages("ated.property-details-period.change-dates-liable.startDate") + +
+ @messages("ated.property-details-period.datesLiable.startDate.hint", periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
- @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"))) +
+
+ + @messages("ated.property-details-period.change-dates-liable.endDate") + +
+ @messages("ated.property-details-period.datesLiable.endDate.hint", periodEndDate(periodKey).toString(messages("ated.date-format.numeric"))) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
@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"))) +
+
+ + @messages("ated.property-details-period.datesLiable.startDate") + +
+ @messages("ated.property-details-period.datesInRelief.startDate.hint", PeriodUtils.periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+ + @messages("ated.property-details-period.datesLiable.endDate") + +
+ @messages("ated.property-details-period.datesInRelief.endDate.hint", PeriodUtils.periodEndDate(periodKey).toString(messages("ated.date-format.numeric"))) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
@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"))) }
@@ -76,34 +76,85 @@

@formHelper(action=controllers.propertyDetails.routes.PeriodInReliefDatesController.save(id, periodKey)) { - - @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.datesInRelief.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.datesInRelief.endDate")), - classes = "govuk-label--s" - )) - )), - items = dateItems - ).withFormField(propertyDetailsForm("endDate"))) +
+
+ + @messages("ated.property-details-period.datesInRelief.startDate") + +
+ @messages("ated.property-details-period.datesInRelief.startDate.hint", PeriodUtils.periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+ + @messages("ated.property-details-period.datesInRelief.endDate") + +
+ @messages("ated.property-details-period.datesInRelief.endDate.hint", PeriodUtils.periodEndDate(periodKey).toString(messages("ated.date-format.numeric"))) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
@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 5869b5cc..90bc723f 100644 --- a/app/views/reliefs/chooseReliefs.scala.html +++ b/app/views/reliefs/chooseReliefs.scala.html @@ -90,130 +90,384 @@ } @rentalBusinessDateConditional = { - @govukDateInput(DateInput( - hint = Some(Hint( - content = Text(Messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate)) - )), - fieldset = Some(Fieldset( - legend = Some(Legend( - content = HtmlContent(messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.rentalBusiness"))) - )) - )), - items = inputItems +
+
+ + @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.rentalBusiness")) + +
+ @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
- ).withFormField(reliefsForm("rentalBusinessDate"))) } @openToPublicDateConditional = { - @govukDateInput(DateInput( - hint = Some(Hint( - content = Text(Messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate)) - )), - fieldset = Some(Fieldset( - legend = Some(Legend( - content = HtmlContent(messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.openToPublic"))) - )) - )), - items = inputItems - ).withFormField(reliefsForm("openToPublicDate"))) +
+
+ + @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.openToPublic")) + +
+ @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
} @propertyDeveloperDateConditional = { - @govukDateInput(DateInput( - hint = Some(Hint( - content = Text(Messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate)) - )), - fieldset = Some(Fieldset( - legend = Some(Legend( - content = HtmlContent(messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.propertyDeveloper"))) - )) - )), - items = inputItems - ).withFormField(reliefsForm("propertyDeveloperDate"))) +
+
+ + @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.propertyDeveloper")) + +
+ @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
} @propertyTradingDateConditional = { - @govukDateInput(DateInput( - hint = Some(Hint( - content = Text(Messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate)) - )), - fieldset = Some(Fieldset( - legend = Some(Legend( - content = HtmlContent(messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.propertyTrading"))) - )) - )), - items = inputItems - ).withFormField(reliefsForm("propertyTradingDate"))) +
+
+ + @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.propertyTrading")) + +
+ @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ } @lendingDateConditional = { - @govukDateInput(DateInput( - hint = Some(Hint( - content = Text(Messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate)) - )), - fieldset = Some(Fieldset( - legend = Some(Legend( - content = HtmlContent(messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.lending"))) - )) - )), - items = inputItems - ).withFormField(reliefsForm("lendingDate"))) +
+
+ + @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.lending")) + +
+ @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
} @employeeOccupationDateConditional = { - @govukDateInput(DateInput( - hint = Some(Hint( - content = Text(Messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate)) - )), - fieldset = Some(Fieldset( - legend = Some(Legend( - content = HtmlContent(messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.employeeOccupation"))) - )) - )), - items = inputItems - ).withFormField(reliefsForm("employeeOccupationDate"))) +
+
+ + @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.employeeOccupation")) + +
+ @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
} @farmHousesDateConditional = { - @govukDateInput(DateInput( - hint = Some(Hint( - content = Text(Messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate)) - )), - fieldset = Some(Fieldset( - legend = Some(Legend( - content = HtmlContent(messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.farmHouses"))) - )) - )), - items = inputItems - ).withFormField(reliefsForm("farmHousesDate"))) +
+
+ + @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.farmHouses")) + +
+ @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
} @socialHousingDateConditional = { - @govukDateInput(DateInput( - hint = Some(Hint( - content = Text(Messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate)) - )), - fieldset = Some(Fieldset( - legend = Some(Legend( - content = HtmlContent(messages("ated.choose-reliefs.date", messages(chooseSingleReliefsocialHousingMessage))) - )) - )), - items = inputItems - ).withFormField(reliefsForm("socialHousingDate"))) +
+
+ + @messages("ated.choose-reliefs.date", messages(chooseSingleReliefsocialHousingMessage)) + +
+ @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ } @equityReleaseDateConditional = { - @govukDateInput(DateInput( - hint = Some(Hint( - content = Text(Messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate)) - )), - fieldset = Some(Fieldset( - legend = Some(Legend( - content = HtmlContent(messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.equityRelease"))) - )) - )), - items = inputItems - ).withFormField(reliefsForm("equityReleaseDate"))) +
+
+ + @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.equityRelease")) + +
+ @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
} @newMain(title = titleBuilder(messages("ated.choose-reliefs.title"), Some(amendedForm)), diff --git a/conf/messages b/conf/messages index 65051291..07711a6b 100644 --- a/conf/messages +++ b/conf/messages @@ -156,15 +156,46 @@ ated.choose-reliefs.equityRelease = Equity release scheme ated.choose-reliefs.equityRelease-reversion = Equity release scheme (home reversion plans) ated.choose-single-relief.rentalBusiness = Rental business +ated.choose-single-relief.rentalBusiness.hiddenContentDay = What day did the Rental business start? +ated.choose-single-relief.rentalBusiness.hiddenContentMonth = What month did the Rental business start? +ated.choose-single-relief.rentalBusiness.hiddenContentYear = What year did the Rental business start? + ated.choose-single-relief.openToPublic = Open to the public +ated.choose-single-relief.openToPublic.hiddenContentDay = What day did the Open to the public start? +ated.choose-single-relief.openToPublic.hiddenContentMonth = What month did the Open to the public start? +ated.choose-single-relief.openToPublic.hiddenContentYear = What year did the Open to the public start? + ated.choose-single-relief.propertyDeveloper = Property developer +ated.choose-single-relief.propertyDeveloper.hiddenContentDay = What day did the Property developer start? +ated.choose-single-relief.propertyDeveloper.hiddenContentMonth = What month did the Property developer start? +ated.choose-single-relief.propertyDeveloper.hiddenContentYear = What year did the Property developer start? + ated.choose-single-relief.propertyTrading = Property trading +ated.choose-single-relief.propertyTrading.hiddenContentDay = What day did the Property trading start? +ated.choose-single-relief.propertyTrading.hiddenContentMonth = What month did the Property trading start? +ated.choose-single-relief.propertyTrading.hiddenContentYear = What year did the Property trading start? + ated.choose-single-relief.lending = Lending +ated.choose-single-relief.lending.hiddenContentDay = What day did the Lending start? +ated.choose-single-relief.lending.hiddenContentMonth = What month did the Lending start? +ated.choose-single-relief.lending.hiddenContentYear = What year did the Lending start? + ated.choose-single-relief.employeeOccupation = Employee occupation +ated.choose-single-relief.employeeOccupation.hiddenContentDay = What day did the Employee occupation start? +ated.choose-single-relief.employeeOccupation.hiddenContentMonth = What month did the Employee occupation start? +ated.choose-single-relief.employeeOccupation.hiddenContentYear = What year did the Employee occupation start? + ated.choose-single-relief.farmHouses = Farmhouse +ated.choose-single-relief.farmHouses.hiddenContentDay = What day did the Farmhouse start? +ated.choose-single-relief.farmHouses.hiddenContentMonth = What month did the Farmhouse start? +ated.choose-single-relief.farmHouses.hiddenContentYear = What year did the Farmhouse start? + ated.choose-single-relief.socialHousing = Social housing ated.choose-single-relief.providerSocialOrHousing = Provider of social housing or housing co-operative ated.choose-single-relief.equityRelease = Equity release scheme (home reversion plans) +ated.choose-single-relief.equityRelease.hiddenContentDay = What day did the Equity release scheme (home reversion plans) start? +ated.choose-single-relief.equityRelease.hiddenContentMonth = What month did the Equity release scheme (home reversion plans) start? +ated.choose-single-relief.equityRelease.hiddenContentYear = What year did the Equity release scheme (home reversion plans) start? ated.choose-reliefs.relief-hint = For example, {0} @@ -181,6 +212,10 @@ ated.choose-reliefs-further.information.text = We do not need any further inform ated.choose-reliefs.error = Select at least one relief ated.choose-reliefs.continue = Save and continue ated.choose-reliefs.date = When did the {0} start? +ated.choose-reliefs.dates = What {0} did the {1} start? +ated.choose-reliefs.dates.day = day +ated.choose-reliefs.dates.month = month +ated.choose-reliefs.dates.year = year ated.choose-reliefs.error.general.reliefs = Select at least one relief ated.choose-reliefs.error.date.mandatory.rentalBusinessDate = Rental business start date must be valid @@ -583,12 +618,22 @@ ated.property-details-period.no = No ated.property-details-period.change-dates-liable.title = Enter the dates this change applies to ated.property-details-period.change-dates-liable.header = Enter the dates this change applies to -ated.property-details-period.change-dates-liable.startDate = What was the first date, in this chargeable period, that this change applies to? -ated.property-details-period.change-dates-liable.endDate = What was the last date, in this chargeable period, that this change applies to? +ated.property-details-period.change-dates-liable.startDate = What was the first date the change applied to in this chargeable period? +ated.property-details-period.change-dates-liable.startDate.hiddenContentDay = The first day the change applied to in this chargeable period +ated.property-details-period.change-dates-liable.startDate.hiddenContentMonth = The first month the change applied to in this chargeable period +ated.property-details-period.change-dates-liable.startDate.hiddenContentYear = The first year the change applied to in this chargeable period + +ated.property-details-period.change-dates-liable.endDate = What was the last date the change applied to in this chargeable period? +ated.property-details-period.change-dates-liable.endDate.hiddenContentDay = The last day the change applied to in this chargeable period +ated.property-details-period.change-dates-liable.endDate.hiddenContentMonth = The last month the change applied to in this chargeable period +ated.property-details-period.change-dates-liable.endDate.hiddenContentYear = The last year the change applied to in this chargeable period ated.property-details-period.datesLiable.title = Enter the dates the property was liable for an ATED charge ated.property-details-period.datesLiable.add.title = Add the dates the property was liable for an ATED charge -ated.property-details-period.datesLiable.startDate = What was the start date in this chargeable period when the property became liable for a charge? +ated.property-details-period.datesLiable.startDate = What was the start date when the property became liable for a charge during this period? +ated.property-details-period.datesLiable.startDate.hiddenContentDay = The start day when the property became liable for a charge during this period +ated.property-details-period.datesLiable.startDate.hiddenContentMonth = The start month when the property became liable for a charge during this period +ated.property-details-period.datesLiable.startDate.hiddenContentYear = The start year when the property became liable for a charge during this period ated.property-details-period.datesLiable.startDate.hint = For example, {0} ated.property-details-period.datesLiable.startDate.error = The liability start date must be in this chargeable period ated.property-details-period.datesLiable.startDate.error.empty = Enter a liability start date @@ -598,7 +643,10 @@ ated.property-details-period.datesLiable.overlap.error = No periods of charge or ated.property-details-period.datesLiable.startDate.messageKey = The liability start date ated.property-details-period.datesLiable.endDate.messageKey = The liability end date -ated.property-details-period.datesLiable.endDate = What was the end date in this chargeable period when the property stopped being liable for a charge? +ated.property-details-period.datesLiable.endDate = What was the end date the property stopped being liable for a charge during this period? +ated.property-details-period.datesLiable.endDate.hiddenContentDay = The end day the property stopped being liable for a charge during this period +ated.property-details-period.datesLiable.endDate.hiddenContentMonth = The end month the property stopped being liable for a charge during this period +ated.property-details-period.datesLiable.endDate.hiddenContentYear = The end year the property stopped being liable for a charge during this period ated.property-details-period.datesLiable.endDate.hint = For example, {0} ated.property-details-period.datesLiable.endDate.error = The liability end date must be in this chargeable period ated.property-details-period.datesLiable.endDate.error.incomplete = Enter a valid liability end date @@ -614,7 +662,12 @@ ated.property-details-period.chooseRelief.error.non-selected = Choose a type of ated.property-details-period.datesInRelief.title = Add the dates when the property was in relief and was not liable for an ATED charge ated.property-details-period.datesInRelief.header = Add the dates when the property was in relief and was not liable for an ATED charge -ated.property-details-period.datesInRelief.startDate = What was the start date in this current period, when the relief started? +ated.property-details-period.datesInRelief.startDate = What was the start date of the relief in this current period? +ated.property-details-period.datesInRelief.startDate.hiddenContentDay = The start day of the relief in this current period? +ated.property-details-period.datesInRelief.startDate.hiddenContentMonth = The start month of the relief in this current period? +ated.property-details-period.datesInRelief.startDate.hiddenContentYear = The start year of the relief in this current period? + + ated.property-details-period.datesInRelief.startDate.hint = For example, {0} ated.property-details-period.datesInRelief.startDate.error = The relief start date must be in this chargeable period ated.property-details-period.datesInRelief.startDate.error.empty = Enter a relief start date @@ -625,7 +678,11 @@ ated.property-details-value.newBuildOccupyDate.error.too-early = The date when t ated.property-details-value.newBuildRegisterDate.error.not-in-period = The registration date must be in the chargeable period ated.property-details-value.newBuildRegisterDate.error.too-early = The date when the property was first occupied must be in the chargeable period -ated.property-details-period.datesInRelief.endDate = What was the end date in this current period, when the relief ended? +ated.property-details-period.datesInRelief.endDate = What was the end date of the relief in this current period? +ated.property-details-period.datesInRelief.endDate.hiddenContentDay = The end day of the relief in this current period? +ated.property-details-period.datesInRelief.endDate.hiddenContentMonth = The end month of the relief in this current period? +ated.property-details-period.datesInRelief.endDate.hiddenContentYear = The end year of the relief in this current period? + ated.property-details-period.datesInRelief.endDate.hint = For example, {0} ated.property-details-period.datesInRelief.endDate.error = The relief end date must be in this chargeable period ated.property-details-period.datesInRelief.endDate.error.empty = Enter a relief end date From bf05adb6b646ec47f683004c21579c3e5bf0d5d0 Mon Sep 17 00:00:00 2001 From: Ben Ryan <37295698+benryan1790@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:09:31 +0000 Subject: [PATCH 2/7] created dual date innput component, implemented on periodDatesLiable --- app/views/helpers/dualDateInputs.scala.html | 152 ++++++++++++++++++ .../periodDatesLiable.scala.html | 105 ++---------- 2 files changed, 166 insertions(+), 91 deletions(-) create mode 100644 app/views/helpers/dualDateInputs.scala.html diff --git a/app/views/helpers/dualDateInputs.scala.html b/app/views/helpers/dualDateInputs.scala.html new file mode 100644 index 00000000..b94ccc15 --- /dev/null +++ b/app/views/helpers/dualDateInputs.scala.html @@ -0,0 +1,152 @@ +@* + * 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" +} + +
+
+ + @messages(legends._1) + +
+ @messages(hints._1, PeriodUtils.periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))) +
+ + @fieldLevelErrorMessage(fields._1) +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ +
+
+ + @messages(legends._2) + +
+ @messages(hints._2, PeriodUtils.periodEndDate(periodKey).toString(messages("ated.date-format.numeric"))) +
+ @fieldLevelErrorMessage(fields._2) +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
\ No newline at end of file diff --git a/app/views/propertyDetails/periodDatesLiable.scala.html b/app/views/propertyDetails/periodDatesLiable.scala.html index 76686376..bd2cad4b 100644 --- a/app/views/propertyDetails/periodDatesLiable.scala.html +++ b/app/views/propertyDetails/periodDatesLiable.scala.html @@ -14,23 +14,21 @@ * limitations under the License. *@ -@import models._ +@import _root_.utils._ @import config.ApplicationConfig +@import models._ @import play.twirl.api.HtmlFormat @import uk.gov.hmrc.govukfrontend.views.html.components._ -@import uk.gov.hmrc.govukfrontend.views.html.components.implicits._ @import views.ViewUtils.titleBuilder @import views.html.helpers._ -@import _root_.utils._ -@import models.StringFormatting._ @this(newMain: newMain, govukButton : GovukButton, govukBackLink : GovukBackLink, govukDateInput : GovukDateInput, - govukErrorSummary : GovukErrorSummary, - formHelper: FormWithCSRF) + govukErrorSummary : GovukErrorSummary, + formHelper: FormWithCSRF) @(id: String, periodKey: Int, propertyDetailsForm: Form[PropertyDetailsDatesLiable], title: String, mode: Option[String], serviceInfoContent: Html = HtmlFormat.empty, backLink: Option[String])(implicit authContext: StandardAuthRetrievals, messages: Messages, request: Request[AnyContent], appConfig: ApplicationConfig) @@ -43,13 +41,6 @@ } } -@dateItems = @{ - Seq(InputItem(attributes = Map("maxLength" -> "2")), - InputItem(attributes = Map("maxLength" -> "2")), - InputItem(attributes = Map("maxLength" -> "4")) - ) -} - @pageHeader = @{title} @newMain(title = titleBuilder(messages(title), Some(propertyDetailsForm)), @@ -74,85 +65,17 @@

@formHelper(action=controllers.propertyDetails.routes.PeriodDatesLiableController.save(id, periodKey, mode)) { -
-
- - @messages("ated.property-details-period.datesLiable.startDate") - -
- @messages("ated.property-details-period.datesInRelief.startDate.hint", PeriodUtils.periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
-
-
- - @messages("ated.property-details-period.datesLiable.endDate") - -
- @messages("ated.property-details-period.datesInRelief.endDate.hint", PeriodUtils.periodEndDate(periodKey).toString(messages("ated.date-format.numeric"))) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+ @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" +} + +
+
+ + @messages(legend) + +
+ @messages(hint, PeriodUtils.periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))) +
+ + @fieldLevelErrorMessage(field) +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
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" -} - -
-
- - @messages(legends._1) - -
- @messages(hints._1, PeriodUtils.periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))) -
- - @fieldLevelErrorMessage(fields._1) -
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- -
-
- - @messages(legends._2) - -
- @messages(hints._2, PeriodUtils.periodEndDate(periodKey).toString(messages("ated.date-format.numeric"))) -
- @fieldLevelErrorMessage(fields._2) -
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
\ 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)) { -
-
- - @messages("ated.property-details-period.datesInRelief.startDate") - -
- @messages("ated.property-details-period.datesInRelief.startDate.hint", PeriodUtils.periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
-
-
- - @messages("ated.property-details-period.datesInRelief.endDate") - -
- @messages("ated.property-details-period.datesInRelief.endDate.hint", PeriodUtils.periodEndDate(periodKey).toString(messages("ated.date-format.numeric"))) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+ @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 = { -
-
- - @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.rentalBusiness")) - -
- @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+@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 = { -
-
- - @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.openToPublic")) - -
- @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+ @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 = { -
-
- - @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.propertyDeveloper")) - -
- @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+ @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 = { -
-
- - @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.propertyTrading")) - -
- @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- + @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 = { -
-
- - @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.lending")) - -
- @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+ @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 = { -
-
- - @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.employeeOccupation")) - -
- @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+ @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 = { -
-
- - @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.farmHouses")) - -
- @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+ @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 = { -
-
- - @messages("ated.choose-reliefs.date", messages(chooseSingleReliefsocialHousingMessage)) - -
- @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+@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 = { -
-
- - @messages("ated.choose-reliefs.date", messages("ated.choose-single-relief.equityRelease")) - -
- @messages("ated.choose-reliefs.relief-hint", formattedPeriodStartDate) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+ @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)) { -
-
- - @messages("ated.property-details-period.change-dates-liable.startDate") - -
- @messages("ated.property-details-period.datesLiable.startDate.hint", periodStartDate(periodKey).toString(messages("ated.date-format.numeric"))) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
-
-
- - @messages("ated.property-details-period.change-dates-liable.endDate") - -
- @messages("ated.property-details-period.datesLiable.endDate.hint", periodEndDate(periodKey).toString(messages("ated.date-format.numeric"))) -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
+ @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 @@ }
-
+
@messages(legend) diff --git a/test/views/editLiability/editLiabilityDatesLiableSpec.scala b/test/views/editLiability/editLiabilityDatesLiableSpec.scala index 08cd26e3..7a88ff39 100644 --- a/test/views/editLiability/editLiabilityDatesLiableSpec.scala +++ b/test/views/editLiability/editLiabilityDatesLiableSpec.scala @@ -64,18 +64,18 @@ class editLiabilityDatesLiableSpec extends AnyFeatureSpec with GuiceOneAppPerSui Then("The date fields should have the correct titles") - assert(document.getElementById("startDate").text === "Day Month Year") - assert(document.select("legend.govuk-fieldset__legend").first.text.contains("What was the first date, in this chargeable period, that this change applies to?")) - assert(document.select("legend.govuk-fieldset__legend").get(1).text.contains("What was the last date, in this chargeable period, that this change applies to?")) + assert(document.getElementById("startDate").text === "Day The first day the change applied to in this chargeable period Month The first month the change applied to in this chargeable period Year The first year the change applied to in this chargeable period") + assert(document.select("legend.govuk-fieldset__legend").first.text.contains("What was the first date the change applied to in this chargeable period?")) + assert(document.select("legend.govuk-fieldset__legend").get(1).text.contains("What was the last date the change applied to in this chargeable period?")) assert(document.getElementById("startDate-hint").text === "For example, 1 4 2015") - assert(document.getElementsByAttributeValue("for", "startDate.day").text === "Day") - assert(document.getElementsByAttributeValue("for", "startDate.month").text === "Month") - assert(document.getElementsByAttributeValue("for", "startDate.year").text === "Year") - assert(document.getElementById("endDate").text === "Day Month Year") - assert(document.getElementsByAttributeValue("for", "endDate.day").text === "Day") - assert(document.getElementsByAttributeValue("for", "endDate.month").text === "Month") - assert(document.getElementsByAttributeValue("for", "endDate.year").text === "Year") - assert(document.getElementById("endDate-hint").text === "For example, 31 3 2016") + assert(document.getElementsByAttributeValue("for", "startDate.day").text === "Day The first day the change applied to in this chargeable period") + assert(document.getElementsByAttributeValue("for", "startDate.month").text === "Month The first month the change applied to in this chargeable period") + assert(document.getElementsByAttributeValue("for", "startDate.year").text === "Year The first year the change applied to in this chargeable period") + assert(document.getElementById("endDate").text === "Day The last day the change applied to in this chargeable period Month The last month the change applied to in this chargeable period Year The last year the change applied to in this chargeable period") + assert(document.getElementsByAttributeValue("for", "endDate.day").text === "Day The last day the change applied to in this chargeable period") + assert(document.getElementsByAttributeValue("for", "endDate.month").text === "Month The last month the change applied to in this chargeable period") + assert(document.getElementsByAttributeValue("for", "endDate.year").text === "Year The last year the change applied to in this chargeable period") + assert(document.getElementById("endDate-hint").text === "For example, 1 4 2015") Then("The submit button should have the correct name") assert(document.getElementById("submit").text() === "Save and continue") From 4e257220ec76a83e49b1a22f01bf8056bc0a8a9f Mon Sep 17 00:00:00 2001 From: Russell Thorn <1692222+russellthorn@users.noreply.github.com> Date: Fri, 17 May 2024 11:06:42 +0100 Subject: [PATCH 6/7] Remove unused code from page head --- .../editLiability/editLiabilityDatesLiable.scala.html | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/views/editLiability/editLiabilityDatesLiable.scala.html b/app/views/editLiability/editLiabilityDatesLiable.scala.html index 60e6a680..dfd62476 100644 --- a/app/views/editLiability/editLiabilityDatesLiable.scala.html +++ b/app/views/editLiability/editLiabilityDatesLiable.scala.html @@ -48,13 +48,6 @@ } } -@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.change-dates-liable.title"),Some(propertyDetailsForm)), serviceInfoContent = serviceInfoContent) { @backLinkHtml From d91f59b9582d9a8918aec01edff329128f8e6ee6 Mon Sep 17 00:00:00 2001 From: Russell Thorn <1692222+russellthorn@users.noreply.github.com> Date: Fri, 17 May 2024 16:27:57 +0100 Subject: [PATCH 7/7] Code tweaks for aria-describedby --- app/views/helpers/dateInput.scala.html | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/views/helpers/dateInput.scala.html b/app/views/helpers/dateInput.scala.html index 00c83dae..4579cdba 100644 --- a/app/views/helpers/dateInput.scala.html +++ b/app/views/helpers/dateInput.scala.html @@ -28,7 +28,7 @@ periodKey: Int, form: Form[_])(implicit messages: Messages) -@formGroupErrorClass(field: String) = @{ +@formGroupErrorClass() = @{ if(form.errors.exists(_.key.contains(field))) { "govuk-form-group govuk-form-group--error" } else { @@ -36,7 +36,7 @@ } } -@fieldLevelErrorClass(field: String, dateField: String) = @{ +@fieldLevelErrorClass(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" @@ -45,7 +45,7 @@ } } -@fieldLevelErrorMessage(field: String) = @{ +@fieldLevelErrorMessage() = @{ val message = form.errors.collect { case e if e.key.startsWith(field) => e.format @@ -61,23 +61,23 @@ } -@ariaDescribedby(field: String) = @{ - form.error(field) match { - case Some(_) => s"$field-hint $field-error" - case _ => s"$field-hint" +@ariaDescribedby() = @{ + form.errors.filter(_.key.contains(field)) match { + case x :: _ => s"$field-hint $field-error" + case Nil => s"$field-hint" } } -@fieldValue(field: String) = @{ - form(field).value.map(x => s"value=$x") +@fieldValue(value: String) = @{ + form(value).value.map(x => s"value=$x") } -@id(field: String, dateField: String) = @{ +@id(dateField: String) = @{ s"$field.$dateField" } -
-
+
+
@messages(legend) @@ -85,33 +85,33 @@ @messages(hint, PeriodUtils.periodStartDate(periodKey).toString(messages("ated.date-format.numeric")))
- @fieldLevelErrorMessage(field) + @fieldLevelErrorMessage()
-
-
-