-
Notifications
You must be signed in to change notification settings - Fork 1
[DTR-4543] CIS AMR Screen Ticket MRAR06 - What do you want to amend? #183
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
4
commits into
main
Choose a base branch
from
DTR-4543
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
4 commits
Select commit
Hold shift + click to select a range
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
71 changes: 71 additions & 0 deletions
71
app/controllers/amend/WhatDoYouWantToAmendStandardController.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,71 @@ | ||
| /* | ||
| * 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.WhatDoYouWantToAmendStandardFormProvider | ||
| import javax.inject.Inject | ||
| import models.NormalMode | ||
| import navigation.Navigator | ||
| import pages.amend.WhatDoYouWantToAmendStandardPage | ||
| 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.WhatDoYouWantToAmendStandardView | ||
|
|
||
| import scala.concurrent.{ExecutionContext, Future} | ||
|
|
||
| class WhatDoYouWantToAmendStandardController @Inject() ( | ||
| override val messagesApi: MessagesApi, | ||
| sessionRepository: SessionRepository, | ||
| navigator: Navigator, | ||
| identify: IdentifierAction, | ||
| getData: DataRetrievalAction, | ||
| requireData: DataRequiredAction, | ||
| formProvider: WhatDoYouWantToAmendStandardFormProvider, | ||
| val controllerComponents: MessagesControllerComponents, | ||
| view: WhatDoYouWantToAmendStandardView | ||
| )(implicit ec: ExecutionContext) | ||
| extends FrontendBaseController | ||
| with I18nSupport { | ||
|
|
||
| val form = formProvider() | ||
|
|
||
| def onPageLoad(): Action[AnyContent] = (identify andThen getData andThen requireData) { implicit request => | ||
|
|
||
| val preparedForm = request.userAnswers.get(WhatDoYouWantToAmendStandardPage) match { | ||
| case None => form | ||
| case Some(value) => form.fill(value) | ||
| } | ||
|
|
||
| Ok(view(preparedForm)) | ||
| } | ||
|
|
||
| def onSubmit(): 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(WhatDoYouWantToAmendStandardPage, value)) | ||
| _ <- sessionRepository.set(updatedAnswers) | ||
| } yield Redirect(navigator.nextPage(WhatDoYouWantToAmendStandardPage, NormalMode, updatedAnswers)) | ||
| ) | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
app/forms/amend/WhatDoYouWantToAmendStandardFormProvider.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,30 @@ | ||
| /* | ||
| * 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.WhatDoYouWantToAmendStandard | ||
|
|
||
| class WhatDoYouWantToAmendStandardFormProvider @Inject() extends Mappings { | ||
|
|
||
| def apply(): Form[WhatDoYouWantToAmendStandard] = | ||
| Form( | ||
| "value" -> enumerable[WhatDoYouWantToAmendStandard]("amend.whatDoYouWantToAmendStandard.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,48 @@ | ||
| /* | ||
| * 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 WhatDoYouWantToAmendStandard | ||
|
|
||
| object WhatDoYouWantToAmendStandard extends Enumerable.Implicits { | ||
|
|
||
| case object AmendToNilReturn extends WithName("amendToNilReturn") with WhatDoYouWantToAmendStandard | ||
| case object AmendPaymentOrSubcontractorDetails | ||
| extends WithName("amendPaymentOrSubcontractorDetails") | ||
| with WhatDoYouWantToAmendStandard | ||
|
|
||
| val values: Seq[WhatDoYouWantToAmendStandard] = Seq( | ||
| AmendToNilReturn, | ||
| AmendPaymentOrSubcontractorDetails | ||
| ) | ||
|
|
||
| def options(implicit messages: Messages): Seq[RadioItem] = values.zipWithIndex.map { case (value, index) => | ||
| RadioItem( | ||
| content = Text(messages(s"amend.whatDoYouWantToAmendStandard.${value.toString}")), | ||
| value = Some(value.toString), | ||
| id = Some(s"value_$index") | ||
| ) | ||
| } | ||
|
|
||
| implicit val enumerable: Enumerable[WhatDoYouWantToAmendStandard] = | ||
| 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.WhatDoYouWantToAmendStandard | ||
| import pages.QuestionPage | ||
| import play.api.libs.json.JsPath | ||
|
|
||
| case object WhatDoYouWantToAmendStandardPage extends QuestionPage[WhatDoYouWantToAmendStandard] { | ||
|
|
||
| override def path: JsPath = JsPath \ toString | ||
|
|
||
| override def toString: String = "whatDoYouWantToAmendStandard" | ||
| } |
49 changes: 49 additions & 0 deletions
49
app/views/amend/WhatDoYouWantToAmendStandardView.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,49 @@ | ||
| @* | ||
| * 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.WhatDoYouWantToAmendStandard | ||
|
|
||
| @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.whatDoYouWantToAmendStandard.title"))) { | ||
|
|
||
| @formHelper(action = controllers.amend.routes.WhatDoYouWantToAmendStandardController.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.whatDoYouWantToAmendStandard.heading")).asPageHeading(), | ||
| items = WhatDoYouWantToAmendStandard.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.