-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from hmrc/DAC6-3043-cya
Dac6 3043: Update Check your answers
- Loading branch information
Showing
35 changed files
with
690 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package utils | ||
|
||
import models.{Address, AddressLookup} | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.content.HtmlContent | ||
|
||
object AddressHelper { | ||
|
||
def formatAddress(address: AddressLookup): String = { | ||
val lines = Seq( | ||
address.addressLine1, | ||
address.addressLine2, | ||
address.addressLine3, | ||
address.addressLine4, | ||
address.town, | ||
address.postcode, | ||
address.county | ||
) | ||
.collect { | ||
case s: String => s | ||
case Some(s) => s | ||
} | ||
lines.mkString(", ") | ||
} | ||
|
||
def formatAddress(address: Address): String = { | ||
val lines = Seq(address.addressLine1, | ||
address.addressLine2, | ||
address.addressLine3, | ||
address.addressLine4, | ||
address.country, | ||
address.postCode, | ||
address.country.description | ||
) | ||
.collect { | ||
case s: String => s | ||
case Some(s) => s | ||
} | ||
lines.mkString(", ") | ||
} | ||
|
||
def formatAddressBlock(address: Address): HtmlContent = { | ||
val lines = Seq(address.addressLine1, | ||
address.addressLine2, | ||
address.addressLine3, | ||
address.addressLine4, | ||
address.country, | ||
address.postCode, | ||
address.country.description | ||
) | ||
.collect { | ||
case s: String => s | ||
case Some(s) => s | ||
} | ||
val block = lines | ||
.map( | ||
line => s"<p class='govuk-!-margin-top-0 govuk-!-margin-bottom-0'>$line</p>" | ||
) | ||
.mkString("") | ||
HtmlContent(block) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package viewmodels.checkAnswers | ||
|
||
import models.{CheckMode, UserAnswers} | ||
import pages.addFinancialInstitution.AddressLookupPage | ||
import play.api.i18n.Messages | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.summarylist.SummaryListRow | ||
import utils.AddressHelper.formatAddressBlock | ||
import viewmodels.checkAnswers.CheckYourAnswersViewModel.accessibleActionItem | ||
import viewmodels.govuk.summarylist._ | ||
import viewmodels.implicits._ | ||
|
||
object AddressLookupSummary { | ||
|
||
def row(answers: UserAnswers)(implicit messages: Messages): Option[SummaryListRow] = | ||
answers.get(AddressLookupPage).map { | ||
answer => | ||
SummaryListRowViewModel( | ||
key = "mainAddress.checkYourAnswersLabel", | ||
value = ValueViewModel(formatAddressBlock(answer.head.toAddress)), | ||
actions = Seq( | ||
accessibleActionItem("site.change", controllers.addFinancialInstitution.routes.WhereIsFIBasedController.onPageLoad(CheckMode).url) | ||
.withVisuallyHiddenText(messages("mainAddress.change.hidden")) | ||
) | ||
) | ||
} | ||
|
||
} |
89 changes: 89 additions & 0 deletions
89
app/viewmodels/checkAnswers/CheckYourAnswersViewModel.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package viewmodels.checkAnswers | ||
|
||
import models.UserAnswers | ||
import pages.addFinancialInstitution._ | ||
import play.api.i18n.Messages | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.content.HtmlContent | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.summarylist.{ActionItem, SummaryListRow} | ||
import viewmodels.govuk.summarylist._ | ||
|
||
object CheckYourAnswersViewModel { | ||
|
||
def accessibleActionItem(messageKey: String, href: String)(implicit messages: Messages): ActionItem = | ||
ActionItemViewModel( | ||
content = HtmlContent( | ||
s""" | ||
|<span aria-hidden="true">${messages(messageKey)}</span> | ||
|""".stripMargin | ||
), | ||
href = href | ||
) | ||
|
||
private def getAddressRow(ua: UserAnswers)(implicit messages: Messages) = { | ||
val addressLookup = AddressLookupSummary.row(ua) | ||
val nonUkAddress = NonUkAddressSummary.row(ua) | ||
val ukAddress = UkAddressSummary.row(ua) | ||
|
||
(addressLookup.isDefined, nonUkAddress.isDefined, ukAddress.isDefined) match { | ||
case (false, false, true) => ukAddress | ||
case (false, true, false) => nonUkAddress | ||
case (true, false, false) => addressLookup | ||
case (_, _, _) => None | ||
} | ||
|
||
} | ||
|
||
private def getGIINRows(ua: UserAnswers)(implicit messages: Messages): Seq[SummaryListRow] = { | ||
val sendReports = ua.get(SendReportsPage) | ||
val haveGIIN = ua.get(HaveGIINPage) | ||
|
||
(sendReports, haveGIIN) match { | ||
case (Some(true), None) => Seq(WhatIsGIINSummary.row(ua)).flatten | ||
case (Some(false), Some(true)) => Seq(HaveGIINSummary.row(ua), WhatIsGIINSummary.row(ua)).flatten | ||
case (Some(false), Some(false)) => Seq(HaveGIINSummary.row(ua)).flatten | ||
case (_, _) => Seq.empty | ||
} | ||
} | ||
|
||
def getFinancialInstitutionSummaries(ua: UserAnswers)(implicit messages: Messages): Seq[SummaryListRow] = | ||
Seq( | ||
ReportForRegisteredBusinessSummary.row(ua), | ||
NameOfFinancialInstitutionSummary.row(ua), | ||
HaveUniqueTaxpayerReferenceSummary.row(ua), | ||
WhatIsUniqueTaxpayerReferenceSummary.row(ua), | ||
SendReportsSummary.row(ua), | ||
getGIINRows(ua), | ||
getAddressRow(ua) | ||
).flatten | ||
|
||
def getFirstContactSummaries(ua: UserAnswers)(implicit messages: Messages): Seq[SummaryListRow] = Seq( | ||
FirstContactNameSummary.row(ua), | ||
FirstContactEmailSummary.row(ua), | ||
FirstContactPhoneNumberSummary.row(ua) | ||
).flatten | ||
|
||
def getSecondContactSummaries(ua: UserAnswers)(implicit messages: Messages): Seq[SummaryListRow] = | ||
Seq( | ||
SecondContactExistsSummary.row(ua), | ||
SecondContactNameSummary.row(ua), | ||
SecondContactEmailSummary.row(ua), | ||
SecondContactPhoneNumberSummary.row(ua) | ||
).flatten | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.