-
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.
BST-111580 parts unavailable screen supplied
- Loading branch information
1 parent
d718699
commit a184de9
Showing
15 changed files
with
583 additions
and
14 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
app/controllers/aboutyouandtheproperty/PartsUnavailableController.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,93 @@ | ||
/* | ||
* 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 controllers.aboutyouandtheproperty | ||
|
||
import actions.{SessionRequest, WithSessionRefiner} | ||
import controllers.FORDataCaptureController | ||
import form.aboutyouandtheproperty.PartsUnavailableForm.partsUnavailableForm | ||
import models.submissions.aboutyouandtheproperty.AboutYouAndThePropertyPartTwo.updateAboutYouAndThePropertyPartTwo | ||
import models.submissions.common.AnswersYesNo | ||
import navigation.AboutYouAndThePropertyNavigator | ||
import navigation.identifiers.PartsUnavailableId | ||
import play.api.Logging | ||
import play.api.i18n.I18nSupport | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import repositories.SessionRepo | ||
import views.html.aboutyouandtheproperty.partsUnavailable | ||
|
||
import javax.inject.{Inject, Named, Singleton} | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
@Singleton | ||
class PartsUnavailableController @Inject() ( | ||
mcc: MessagesControllerComponents, | ||
navigator: AboutYouAndThePropertyNavigator, | ||
view: partsUnavailable, | ||
withSessionRefiner: WithSessionRefiner, | ||
@Named("session") val session: SessionRepo | ||
)(implicit val ec: ExecutionContext) | ||
extends FORDataCaptureController(mcc) | ||
with I18nSupport | ||
with Logging { | ||
|
||
def show: Action[AnyContent] = (Action andThen withSessionRefiner).async { implicit request => | ||
Future.successful( | ||
Ok( | ||
view( | ||
request.sessionData.aboutYouAndThePropertyPartTwo.flatMap(_.partsUnavailable) match { | ||
case Some(tiedForGoods) => partsUnavailableForm.fill(tiedForGoods) | ||
case _ => partsUnavailableForm | ||
}, | ||
calculateBackLink, | ||
request.sessionData.toSummary | ||
) | ||
) | ||
) | ||
} | ||
|
||
def submit: Action[AnyContent] = (Action andThen withSessionRefiner).async { implicit request => | ||
continueOrSaveAsDraft[AnswersYesNo]( | ||
partsUnavailableForm, | ||
formWithErrors => | ||
BadRequest( | ||
view( | ||
formWithErrors, | ||
calculateBackLink, | ||
request.sessionData.toSummary | ||
) | ||
), | ||
data => { | ||
val updatedData = updateAboutYouAndThePropertyPartTwo(_.copy(partsUnavailable = Some(data))) | ||
session | ||
.saveOrUpdate(updatedData) | ||
.map(_ => Redirect(navigator.nextPage(PartsUnavailableId, updatedData).apply(updatedData))) | ||
} | ||
) | ||
} | ||
|
||
private def calculateBackLink(implicit request: SessionRequest[AnyContent]): String = | ||
navigator.from match { | ||
case "CYA" => controllers.aboutyouandtheproperty.routes.CheckYourAnswersAboutThePropertyController.show().url | ||
case "TL" => s"${controllers.routes.TaskListController.show().url}#family-usage" | ||
case _ => | ||
if (request.sessionData.isWelsh) { | ||
controllers.aboutyouandtheproperty.routes.CompletedCommercialLettingsWelshController.show().url | ||
} else { | ||
controllers.aboutyouandtheproperty.routes.CompletedCommercialLettingsController.show().url | ||
} | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
app/form/aboutyouandtheproperty/PartsUnavailableForm.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,32 @@ | ||
/* | ||
* 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 form.aboutyouandtheproperty | ||
|
||
import form.MappingSupport.createYesNoType | ||
import models.submissions.common.AnswersYesNo | ||
import play.api.data.Form | ||
import play.api.data.Forms.single | ||
|
||
object PartsUnavailableForm { | ||
|
||
val partsUnavailableForm: Form[AnswersYesNo] = | ||
Form( | ||
single( | ||
"partsUnavailable" -> createYesNoType("error.partsUnavailable.required") | ||
) | ||
) | ||
} |
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
52 changes: 52 additions & 0 deletions
52
app/views/aboutyouandtheproperty/partsUnavailable.scala.html
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,52 @@ | ||
@* | ||
* 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 models.submissions.common.AnswersYesNo | ||
@import uk.gov.hmrc.govukfrontend.views.html.components._ | ||
@import models.pages.Summary | ||
|
||
@this(layout: Layout, | ||
govukButton: GovukButton, | ||
govukRadios: GovukRadios, | ||
formWithCSRF: FormWithCSRF | ||
) | ||
|
||
@(theForm: Form[AnswersYesNo],backLink: String, summary: Summary)(implicit request: Request[?], messages: Messages) | ||
|
||
@layout( | ||
pageHeading = messages("partsUnavailable.heading"), | ||
showSection = true, | ||
summary = Option(summary), | ||
sectionName = messages("label.section.aboutTheProperty"), | ||
backLinkUrl = backLink, | ||
theForm = theForm | ||
) { | ||
|
||
<p class="govuk-body">@messages("partsUnavailable.p")</p> | ||
|
||
@formWithCSRF(action = controllers.aboutyouandtheproperty.routes.PartsUnavailableController.submit()) { | ||
|
||
@includes.radioButtonsYesNo( | ||
govukRadios, | ||
theForm, | ||
"partsUnavailable", | ||
"partsUnavailable.label", | ||
classes = "govuk-fieldset__legend--m", | ||
) | ||
|
||
@includes.continueSaveAsDraftButtons(govukButton) | ||
} | ||
} |
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
Oops, something went wrong.