-
Notifications
You must be signed in to change notification settings - Fork 1
[DTR-4546] CIS AMR Screen Ticket MRAR09 - Are you sure you want to amend this return to a nil return? #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wg-hmrc
wants to merge
5
commits into
main
Choose a base branch
from
DTR-4546
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7998740
[DTR-4546] Adding scaffolding
wg-hmrc 70b98e7
[DTR-4546] Adding final changes
wg-hmrc 8bbf705
[DTR-4546] Resolving PR comment
wg-hmrc 79dbf7c
[DTR-4546] resolving PR comments
wg-hmrc 2546ef5
[DTR-4546] fixing failed test
wg-hmrc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
app/controllers/amend/AreYouSureYouWantToAmendYesNoController.scala
This file contains hidden or 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,72 @@ | ||
| /* | ||
| * Copyright 2026 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 controllers.amend | ||
|
|
||
| import controllers.actions._ | ||
| import forms.amend.AreYouSureYouWantToAmendYesNoFormProvider | ||
| import javax.inject.Inject | ||
| import models.Mode | ||
| import navigation.Navigator | ||
| import pages.amend.AreYouSureYouWantToAmendYesNoPage | ||
| import play.api.i18n.{I18nSupport, MessagesApi} | ||
| import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
| import repositories.SessionRepository | ||
| import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController | ||
| import views.html.amend.AreYouSureYouWantToAmendYesNoView | ||
|
|
||
| import scala.concurrent.{ExecutionContext, Future} | ||
|
|
||
| class AreYouSureYouWantToAmendYesNoController @Inject() ( | ||
| override val messagesApi: MessagesApi, | ||
| sessionRepository: SessionRepository, | ||
| navigator: Navigator, | ||
| identify: IdentifierAction, | ||
| getData: DataRetrievalAction, | ||
| requireData: DataRequiredAction, | ||
| formProvider: AreYouSureYouWantToAmendYesNoFormProvider, | ||
| val controllerComponents: MessagesControllerComponents, | ||
| view: AreYouSureYouWantToAmendYesNoView | ||
| )(implicit ec: ExecutionContext) | ||
| extends FrontendBaseController | ||
| with I18nSupport { | ||
|
|
||
| val form = formProvider() | ||
|
|
||
| def onPageLoad(mode: Mode): Action[AnyContent] = (identify andThen getData andThen requireData) { implicit request => | ||
|
|
||
| val preparedForm = request.userAnswers.get(AreYouSureYouWantToAmendYesNoPage) match { | ||
| case None => form | ||
| case Some(value) => form.fill(value) | ||
| } | ||
|
|
||
| Ok(view(preparedForm)) | ||
| } | ||
|
|
||
| def onSubmit(mode: Mode): Action[AnyContent] = (identify andThen getData andThen requireData).async { | ||
| implicit request => | ||
| form | ||
| .bindFromRequest() | ||
| .fold( | ||
| formWithErrors => Future.successful(BadRequest(view(formWithErrors))), | ||
| value => | ||
| for { | ||
| updatedAnswers <- Future.fromTry(request.userAnswers.set(AreYouSureYouWantToAmendYesNoPage, value)) | ||
| _ <- sessionRepository.set(updatedAnswers) | ||
| } yield Redirect(navigator.nextPage(AreYouSureYouWantToAmendYesNoPage, mode, updatedAnswers)) | ||
| ) | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
app/forms/amend/AreYouSureYouWantToAmendYesNoFormProvider.scala
This file contains hidden or 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,31 @@ | ||
| /* | ||
| * Copyright 2026 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 forms.amend | ||
|
|
||
| import javax.inject.Inject | ||
|
|
||
| import forms.mappings.Mappings | ||
| import play.api.data.Form | ||
| import models.amend.AreYouSureYouWantToAmendYesNo | ||
|
|
||
| class AreYouSureYouWantToAmendYesNoFormProvider @Inject() extends Mappings { | ||
|
|
||
| def apply(): Form[AreYouSureYouWantToAmendYesNo] = | ||
| Form( | ||
| "value" -> enumerable[AreYouSureYouWantToAmendYesNo]("amend.areYouSureYouWantToAmendYesNo.error.required") | ||
| ) | ||
| } |
This file contains hidden or 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,46 @@ | ||
| /* | ||
| * Copyright 2026 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 models.amend | ||
|
|
||
| import models.{Enumerable, WithName} | ||
| import play.api.i18n.Messages | ||
| import uk.gov.hmrc.govukfrontend.views.Aliases.Text | ||
| import uk.gov.hmrc.govukfrontend.views.viewmodels.radios.RadioItem | ||
|
|
||
| sealed trait AreYouSureYouWantToAmendYesNo | ||
|
|
||
| object AreYouSureYouWantToAmendYesNo extends Enumerable.Implicits { | ||
|
|
||
| case object Yes extends WithName("yes") with AreYouSureYouWantToAmendYesNo | ||
| case object No extends WithName("no") with AreYouSureYouWantToAmendYesNo | ||
|
|
||
| val values: Seq[AreYouSureYouWantToAmendYesNo] = Seq( | ||
| Yes, | ||
| No | ||
| ) | ||
|
|
||
| def options(implicit messages: Messages): Seq[RadioItem] = values.zipWithIndex.map { case (value, index) => | ||
| RadioItem( | ||
| content = Text(messages(s"amend.areYouSureYouWantToAmendYesNo.${value.toString}")), | ||
| value = Some(value.toString), | ||
| id = Some(s"value_$index") | ||
| ) | ||
| } | ||
|
|
||
| implicit val enumerable: Enumerable[AreYouSureYouWantToAmendYesNo] = | ||
| Enumerable(values.map(v => v.toString -> v): _*) | ||
| } |
This file contains hidden or 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,28 @@ | ||
| /* | ||
| * Copyright 2026 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 pages.amend | ||
|
|
||
| import models.amend.AreYouSureYouWantToAmendYesNo | ||
| import pages.QuestionPage | ||
| import play.api.libs.json.JsPath | ||
|
|
||
| case object AreYouSureYouWantToAmendYesNoPage extends QuestionPage[AreYouSureYouWantToAmendYesNo] { | ||
|
|
||
| override def path: JsPath = JsPath \ toString | ||
|
|
||
| override def toString: String = "areYouSureYouWantToAmendYesNo" | ||
| } |
50 changes: 50 additions & 0 deletions
50
app/views/amend/AreYouSureYouWantToAmendYesNoView.scala.html
This file contains hidden or 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,50 @@ | ||
| @* | ||
| * Copyright 2026 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 models.amend.AreYouSureYouWantToAmendYesNo | ||
| @import viewmodels.LegendSize | ||
|
|
||
| @this( | ||
| layout: templates.Layout, | ||
| formHelper: FormWithCSRF, | ||
| govukErrorSummary: GovukErrorSummary, | ||
| govukRadios: GovukRadios, | ||
| govukButton: GovukButton | ||
| ) | ||
|
|
||
| @(form: Form[_])(implicit request: Request[_], messages: Messages) | ||
|
|
||
| @layout(pageTitle = title(form, messages("amend.areYouSureYouWantToAmendYesNo.title"))) { | ||
|
|
||
| @formHelper(action = controllers.amend.routes.AreYouSureYouWantToAmendYesNoController.onSubmit(), Symbol("autoComplete") -> "off") { | ||
|
|
||
| @if(form.errors.nonEmpty) { | ||
| @govukErrorSummary(ErrorSummaryViewModel(form, errorLinkOverrides = Map("value" -> "value_0"))) | ||
| } | ||
|
|
||
| @govukRadios( | ||
| RadiosViewModel( | ||
| field = form("value"), | ||
| legend = LegendViewModel(messages("amend.areYouSureYouWantToAmendYesNo.heading")).asPageHeading(LegendSize.Large), | ||
| items = AreYouSureYouWantToAmendYesNo.options | ||
| ) | ||
| ) | ||
|
|
||
| @govukButton( | ||
| ButtonViewModel(messages("site.continue")) | ||
| ) | ||
| } | ||
| } |
This file contains hidden or 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
|
jassalrichy marked this conversation as resolved.
|
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.