Skip to content

Commit

Permalink
MCSC-1169 Accessibility fixes (Calculation) - Part 1 (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
bharti5verma authored Nov 19, 2024
1 parent c59cd32 commit 356d2b3
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import forms.annualallowance.taxyear.ThresholdIncomeFormProvider
import models.tasklist.sections.AASection
import models.{Mode, Period}
import pages.annualallowance.taxyear.ThresholdIncomePage
import play.api.i18n.{I18nSupport, MessagesApi}
import play.api.i18n.{I18nSupport, Messages, MessagesApi}
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
import services.UserDataService
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
import views.html.annualallowance.taxyear.ThresholdIncomeView

import java.time.format.DateTimeFormatter
import java.util.Locale
import javax.inject.Inject
import scala.concurrent.{ExecutionContext, Future}

Expand All @@ -51,7 +53,7 @@ class ThresholdIncomeController @Inject() (
case Some(value) => form.fill(value)
}

Ok(view(preparedForm, mode, period))
Ok(view(preparedForm, mode, period, startEndDate(period)))
}

def onSubmit(mode: Mode, period: Period): Action[AnyContent] =
Expand All @@ -60,7 +62,7 @@ class ThresholdIncomeController @Inject() (
form
.bindFromRequest()
.fold(
formWithErrors => Future.successful(BadRequest(view(formWithErrors, mode, period))),
formWithErrors => Future.successful(BadRequest(view(formWithErrors, mode, period, startEndDate(period)))),
value =>
for {
updatedAnswers <- Future.fromTry(request.userAnswers.set(ThresholdIncomePage(period), value))
Expand All @@ -70,4 +72,10 @@ class ThresholdIncomeController @Inject() (
} yield Redirect(redirectUrl)
)
}

private def startEndDate(period: Period)(implicit messages: Messages): String = {
val languageTag = if (messages.lang.code == "cy") "cy" else "en"
val formatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.forLanguageTag(languageTag))
period.start.format(formatter) + " " + messages("startEndDateAnd") + " " + period.end.format(formatter)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object HowMuchAAChargeSchemePaidSummary {
period.start.format(formatter) + " " + messages("startEndDateTo") + " " + period.end.format(formatter)

SummaryListRowViewModel(
key = "howMuchAAChargeSchemePaid.checkYourAnswersLabel",
key = messages("howMuchAAChargeSchemePaid.checkYourAnswersLabel", startEndDate),
value = ValueViewModel(HtmlContent(currencyFormat(answer))),
actions = Seq(
ActionItemViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object HowMuchAAChargeYouPaidSummary {
period.start.format(formatter) + " " + messages("startEndDateTo") + " " + period.end.format(formatter)

SummaryListRowViewModel(
key = "howMuchAAChargeYouPaid.checkYourAnswersLabel",
key = messages("howMuchAAChargeYouPaid.checkYourAnswersLabel", startEndDate),
value = ValueViewModel(HtmlContent(currencyFormat(answer))),
actions = Seq(
ActionItemViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object TradeUnionReliefSummary {
val value = if (answer) "site.yes" else "site.no"

SummaryListRowViewModel(
key = "tradeUnionRelief.checkYourAnswersLabel",
key = messages("tradeUnionRelief.checkYourAnswersLabel", startEndDate),
value = ValueViewModel(value),
actions = Seq(
ActionItemViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object UnionPoliceReliefAmountSummary {
period.start.format(formatter) + " " + messages("startEndDateTo") + " " + period.end.format(formatter)

SummaryListRowViewModel(
key = "unionPoliceReliefAmount.checkYourAnswersLabel",
key = messages("unionPoliceReliefAmount.checkYourAnswersLabel", startEndDate),
value = ValueViewModel(HtmlContent(currencyFormat(answer))),
actions = Seq(
ActionItemViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import uk.gov.hmrc.govukfrontend.views.viewmodels.summarylist.SummaryListRow
import viewmodels.govuk.summarylist._
import viewmodels.implicits._

import java.time.format.DateTimeFormatter
import java.util.Locale

object WhoPaidAAChargeSummary {

def row(answers: UserAnswers, period: Period, schemeIndex: SchemeIndex)(implicit
Expand All @@ -41,8 +44,13 @@ object WhoPaidAAChargeSummary {
answer.schemeName
}

val languageTag = if (messages.lang.code == "cy") "cy" else "en"
val formatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.forLanguageTag(languageTag))
val startEndDate: String =
period.start.format(formatter) + " " + messages("startEndDateTo") + " " + period.end.format(formatter)

SummaryListRowViewModel(
key = messages("whoPaidAACharge.checkYourAnswersLabel", schemeName.getOrElse("")),
key = messages("whoPaidAACharge.checkYourAnswersLabel", schemeName.getOrElse(""), startEndDate),
value = value,
actions = Seq(
ActionItemViewModel(
Expand All @@ -51,7 +59,7 @@ object WhoPaidAAChargeSummary {
.onPageLoad(CheckMode, period, schemeIndex)
.url
)
.withVisuallyHiddenText(messages("whoPaidAACharge.change.hidden", schemeName.getOrElse("")))
.withVisuallyHiddenText(messages("whoPaidAACharge.change.hidden", schemeName.getOrElse(""), startEndDate))
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
continueButton: components.ContinueButton
)

@(form: Form[_], mode: Mode, period: Period)(implicit request: Request[_], messages: Messages)
@(form: Form[_], mode: Mode, period: Period, startEndDate: String)(implicit request: Request[_], messages: Messages)

@contentHint = {
<p class="govuk-body">@messages("thresholdIncome.message1")</p>
Expand Down Expand Up @@ -67,7 +67,7 @@ <h2 class="govuk-heading-m">@messages("thresholdIncome.subHeading1")</h2>
<h2 class="govuk-heading-m">@messages("thresholdIncome.subHeading2." + period)</h2>
}

@layout(pageTitle = title(form, messages("thresholdIncome.title"))) {
@layout(pageTitle = title(form, messages("thresholdIncome.title", startEndDate))) {

@formHelper(action = controllers.annualallowance.taxyear.routes.ThresholdIncomeController.onSubmit(mode, period), 'autoComplete -> "off") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

@(form: Form[_], mode: Mode, period: Period, schemeIndex: SchemeIndex, schemeName: String, startEndDate: String)(implicit request: Request[_], messages: Messages)

@layout(pageTitle = title(form, messages("whoPaidAACharge.title", schemeIndex, schemeName))) {
@layout(pageTitle = title(form, messages("whoPaidAACharge.title", schemeName, startEndDate))) {

@formHelper(action = controllers.annualallowance.taxyear.routes.WhoPaidAAChargeController.onSubmit(mode,period, schemeIndex), Symbol("autoComplete") -> "off") {

Expand Down
Loading

0 comments on commit 356d2b3

Please sign in to comment.