-
Notifications
You must be signed in to change notification settings - Fork 0
NGR-1875 - Added Repairs and Fitted Out page #70
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6364c78
NGR-1875 - Added Repairs and Fitted Out page
peterdrobinson c821aa2
Merge branch 'main' into NGR-1875
peterdrobinson 639f807
NGR-1875 - Amended as per Anna's comments
peterdrobinson 8b44fa2
Merge remote-tracking branch 'origin/NGR-1875' into NGR-1875
peterdrobinson 841fa0c
Merge branch 'main' into NGR-1875
peterdrobinson 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
80 changes: 80 additions & 0 deletions
80
app/uk/gov/hmrc/ngrraldfrontend/controllers/RepairsAndFittingOutController.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,80 @@ | ||
/* | ||
* Copyright 2025 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 uk.gov.hmrc.ngrraldfrontend.controllers | ||
|
||
import play.api.i18n.I18nSupport | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import uk.gov.hmrc.ngrraldfrontend.actions.{AuthRetrievals, DataRetrievalAction} | ||
import uk.gov.hmrc.ngrraldfrontend.config.AppConfig | ||
import uk.gov.hmrc.ngrraldfrontend.models.components.NGRRadio.{buildRadios, simpleNgrRadio} | ||
import uk.gov.hmrc.ngrraldfrontend.models.forms.RepairsAndFittingOutForm | ||
import uk.gov.hmrc.ngrraldfrontend.models.forms.RepairsAndFittingOutForm.form | ||
import uk.gov.hmrc.ngrraldfrontend.models.{Mode, UserAnswers} | ||
import uk.gov.hmrc.ngrraldfrontend.navigation.Navigator | ||
import uk.gov.hmrc.ngrraldfrontend.pages.RepairsAndFittingOutPage | ||
import uk.gov.hmrc.ngrraldfrontend.repo.SessionRepository | ||
import uk.gov.hmrc.ngrraldfrontend.views.html.RepairsAndFittingOutView | ||
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendController | ||
|
||
import javax.inject.Inject | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
class RepairsAndFittingOutController @Inject()(repairsAndFittingView: RepairsAndFittingOutView, | ||
authenticate: AuthRetrievals, | ||
getData: DataRetrievalAction, | ||
sessionRepository: SessionRepository, | ||
navigator: Navigator, | ||
mcc: MessagesControllerComponents)(implicit appConfig: AppConfig, ec: ExecutionContext) | ||
extends FrontendController(mcc) with I18nSupport { | ||
|
||
|
||
def show(mode: Mode): Action[AnyContent] = { | ||
(authenticate andThen getData).async { implicit request => | ||
val preparedForm = request.userAnswers.getOrElse(UserAnswers(request.credId)).get(RepairsAndFittingOutPage) match { | ||
case None => form | ||
case Some(value) => form.fill(RepairsAndFittingOutForm(value.toString)) | ||
} | ||
Future.successful(Ok(repairsAndFittingView( | ||
selectedPropertyAddress = request.property.addressFull, | ||
form = preparedForm, | ||
ngrRadio = buildRadios(preparedForm, RepairsAndFittingOutForm.repairsAndFittingOutRadio), | ||
mode = mode | ||
))) | ||
} | ||
} | ||
|
||
def submit(mode: Mode): Action[AnyContent] = | ||
(authenticate andThen getData).async { implicit request => | ||
form.bindFromRequest().fold( | ||
formWithErrors => { | ||
Future.successful(BadRequest(repairsAndFittingView( | ||
form = formWithErrors, | ||
ngrRadio = buildRadios(formWithErrors, RepairsAndFittingOutForm.repairsAndFittingOutRadio), | ||
selectedPropertyAddress = request.property.addressFull, | ||
mode = mode | ||
))) | ||
}, | ||
radioValue => | ||
for { | ||
updatedAnswers <- Future.fromTry(request.userAnswers.getOrElse(UserAnswers(request.credId)) | ||
.set(RepairsAndFittingOutPage, radioValue.radioValue.toBoolean)) | ||
_ <- sessionRepository.set(updatedAnswers) | ||
} yield Redirect(navigator.nextPage(RepairsAndFittingOutPage, mode, updatedAnswers)) | ||
|
||
) | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
app/uk/gov/hmrc/ngrraldfrontend/models/forms/RepairsAndFittingOutForm.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,61 @@ | ||
/* | ||
* Copyright 2025 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 uk.gov.hmrc.ngrraldfrontend.models.forms | ||
|
||
import play.api.data.Form | ||
import play.api.data.Forms.mapping | ||
import play.api.i18n.* | ||
import play.api.libs.json.{Json, OFormat} | ||
import uk.gov.hmrc.ngrraldfrontend.models.forms.mappings.Mappings | ||
import uk.gov.hmrc.ngrraldfrontend.models.components.NGRRadio | ||
import uk.gov.hmrc.ngrraldfrontend.models.components.NGRRadio.{ngrRadio, noButton, yesButton} | ||
|
||
final case class RepairsAndFittingOutForm(radioValue: String) | ||
|
||
object RepairsAndFittingOutForm extends CommonFormValidators with Mappings { | ||
implicit val format: OFormat[RepairsAndFittingOutForm] = Json.format[RepairsAndFittingOutForm] | ||
|
||
private lazy val radioUnselectedError = "repairsAndFittingOut.empty.error" | ||
val radio = "repairsAndFittingOut-radio-value" | ||
|
||
val messagesApi: MessagesApi = new DefaultMessagesApi() | ||
val lang: Lang = Lang.defaultLang | ||
val messages: Messages = MessagesImpl(lang, messagesApi) | ||
|
||
def unapply(repairsAndFittingOutForm: RepairsAndFittingOutForm): Option[(String)] = | ||
Some(repairsAndFittingOutForm.radioValue) | ||
|
||
def repairsAndFittingOutRadio(implicit messages: Messages): NGRRadio = | ||
ngrRadio( | ||
radioName = radio, | ||
radioButtons = Seq( | ||
yesButton(), | ||
noButton() | ||
), | ||
ngrTitle = "repairsAndFittingOut.header" | ||
) | ||
|
||
def form: Form[RepairsAndFittingOutForm] = { | ||
Form( | ||
mapping( | ||
radio -> radioText(radioUnselectedError), | ||
)(RepairsAndFittingOutForm.apply)(RepairsAndFittingOutForm.unapply) | ||
) | ||
} | ||
|
||
|
||
} |
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
27 changes: 27 additions & 0 deletions
27
app/uk/gov/hmrc/ngrraldfrontend/pages/RepairsAndFittingOutPage.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,27 @@ | ||
/* | ||
* Copyright 2025 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 uk.gov.hmrc.ngrraldfrontend.pages | ||
|
||
import play.api.libs.json.JsPath | ||
|
||
case object RepairsAndFittingOutPage extends QuestionPage[Boolean] { | ||
|
||
override def toString: String = "repairsAndFittingOutPage" | ||
|
||
override def path: JsPath = JsPath \ toString | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
app/uk/gov/hmrc/ngrraldfrontend/views/RepairsAndFittingOutView.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,64 @@ | ||
@* | ||
* Copyright 2025 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. | ||
*@ | ||
|
||
@* | ||
* Copyright 2025 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 uk.gov.hmrc.ngrraldfrontend.config.AppConfig | ||
|
||
@import uk.gov.hmrc.govukfrontend.views.html.components._ | ||
@import uk.gov.hmrc.govukfrontend.views.Aliases._ | ||
@import uk.gov.hmrc.ngrraldfrontend.views.html.components._ | ||
@import uk.gov.hmrc.ngrraldfrontend.viewmodels.govuk.all._ | ||
@import uk.gov.hmrc.ngrraldfrontend.config.AppConfig | ||
@import uk.gov.hmrc.ngrraldfrontend.models.components.NavigationBarContent | ||
@import uk.gov.hmrc.ngrraldfrontend.models.forms.RepairsAndFittingOutForm | ||
|
||
@this( | ||
layout: Layout, | ||
formHelper: FormWithCSRF, | ||
govukErrorSummary: GovukErrorSummary, | ||
govukRadios : GovukRadios, | ||
saveAndContinueButton: saveAndContinueButton | ||
) | ||
|
||
@(selectedPropertyAddress: String, form: Form[RepairsAndFittingOutForm], ngrRadio: Radios, mode: Mode)(implicit request: RequestHeader, messages: Messages, appConfig: AppConfig) | ||
|
||
@layout(pageTitle = Some(messages("repairsAndFittingOut.title")), showBackLink = true, fullWidth = false) { | ||
@formHelper(action = uk.gov.hmrc.ngrraldfrontend.controllers.routes.RepairsAndFittingOutController.submit(mode), Symbol("autoComplete") -> "off") { | ||
@if(form.errors.nonEmpty) { | ||
@govukErrorSummary(ErrorSummaryViewModel(form)) | ||
} | ||
<span class="govuk-caption-m">@selectedPropertyAddress</span> | ||
<h1 class="govuk-heading-l">@messages("repairsAndFittingOut.title")</h1> | ||
<p class="govuk-body">@messages("repairsAndFittingOut.p1")</p> | ||
@govukRadios(ngrRadio) | ||
@saveAndContinueButton(msg = messages("service.continue"), isStartButton = false) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -414,6 +414,12 @@ rentReview.rentReviewMonthsYears.months.maximum.11.error = The number of months | |
rentReview.rentReviewMonthsYears.years.invalid.error = The number of years for how often your rent is reviewed must be a number, like 2 | ||
rentReview.rentReviewMonthsYears.years.maximum.1000.error = How often your rent is reviewed must be 1,000 years or less | ||
|
||
#Repairs and fitting out | ||
repairsAndFittingOut.title = Repairs and fitting out | ||
repairsAndFittingOut.header = Have you done any repairs or fitting out in the property? | ||
repairsAndFittingOut.p1 = Repairs are when you fix things like poor electrical wiring, leaking windows or a broken toilet. Fitting out is when you install things like air conditioning, a kitchen or carpeting. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you've ran the application and see the radio button question(Have you done any repairs or fitting out in the property?). But I don't see the radio question text being here. |
||
repairsAndFittingOut.empty.error = Select yes if you have done any repairs of fitting out in the property | ||
|
||
#How much was the lump sum | ||
howMuchWasTheLumpSum.title = How much was the lump sum? | ||
howMuchWasTheLumpSum.empty.error = Enter the lump sum, in pounds | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous page is already done. Can you please link it? It looks like only new agreement journey will come to this page.