-
Notifications
You must be signed in to change notification settings - Fork 0
NGR-1133 - Added new did you get money from landlord page #67
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
10 commits
Select commit
Hold shift + click to select a range
84daf2f
NGR-1133 - Added new did you get money from landlord page
peterdrobinson 9e8ddb7
Merge branch 'main' into NGR-1133
peterdrobinson f906155
NGR-1133 - Fixed issue
peterdrobinson 305aa7e
NGR-1133 - Resolved test issue
peterdrobinson acd2513
Merge branch 'main' into NGR-1133
peterdrobinson d0de934
NGR-1133 - Amended as per Annas comments
peterdrobinson e124214
NGR-1133 - Merged with main
peterdrobinson cf7907a
NGR-1133 - Merged with main
peterdrobinson e523918
NGR-1133 - Fixed failing test
peterdrobinson ebca6e5
NGR-1133 - Fixed further tests
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/DidYouGetMoneyFromLandlordController.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 | ||
import uk.gov.hmrc.ngrraldfrontend.models.forms.DidYouGetMoneyFromLandlordForm | ||
import uk.gov.hmrc.ngrraldfrontend.models.forms.DidYouGetMoneyFromLandlordForm.form | ||
import uk.gov.hmrc.ngrraldfrontend.models.{Mode, UserAnswers} | ||
import uk.gov.hmrc.ngrraldfrontend.navigation.Navigator | ||
import uk.gov.hmrc.ngrraldfrontend.pages.DidYouGetMoneyFromLandlordPage | ||
import uk.gov.hmrc.ngrraldfrontend.repo.SessionRepository | ||
import uk.gov.hmrc.ngrraldfrontend.views.html.DidYouGetMoneyFromLandlordView | ||
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendController | ||
|
||
import javax.inject.Inject | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
class DidYouGetMoneyFromLandlordController @Inject()(didYouGetMoneyFromLandlordView: DidYouGetMoneyFromLandlordView, | ||
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(DidYouGetMoneyFromLandlordPage) match { | ||
case None => form | ||
case Some(value) => form.fill(DidYouGetMoneyFromLandlordForm(value.toString)) | ||
|
||
} | ||
Future.successful(Ok(didYouGetMoneyFromLandlordView( | ||
selectedPropertyAddress = request.property.addressFull, | ||
form = preparedForm, | ||
ngrRadio = buildRadios(preparedForm, DidYouGetMoneyFromLandlordForm.moneyLandlordRadio), | ||
mode = mode | ||
))) | ||
} | ||
} | ||
|
||
def submit(mode: Mode): Action[AnyContent] = | ||
(authenticate andThen getData).async { implicit request => | ||
form.bindFromRequest().fold( | ||
formWithErrors => { | ||
Future.successful(BadRequest(didYouGetMoneyFromLandlordView( | ||
form = formWithErrors, | ||
ngrRadio = buildRadios(formWithErrors, DidYouGetMoneyFromLandlordForm.moneyLandlordRadio), | ||
selectedPropertyAddress = request.property.addressFull, | ||
mode = mode | ||
))) | ||
}, | ||
radioValue => | ||
for { | ||
updatedAnswers <- Future.fromTry(request.userAnswers.getOrElse(UserAnswers(request.credId)).set(DidYouGetMoneyFromLandlordPage, radioValue.radio.toBoolean)) | ||
_ <- sessionRepository.set(updatedAnswers) | ||
} yield Redirect(navigator.nextPage(DidYouGetMoneyFromLandlordPage, mode, updatedAnswers)) | ||
|
||
) | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
app/uk/gov/hmrc/ngrraldfrontend/models/forms/DidYouGetMoneyFromLandlordForm.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,62 @@ | ||
/* | ||
* 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, optional} | ||
import play.api.data.validation.{Constraint, Invalid, Valid} | ||
import play.api.i18n.* | ||
import play.api.libs.json.{Json, OFormat} | ||
import uk.gov.hmrc.govukfrontend.views.Aliases.Text | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.fieldset.Legend | ||
import uk.gov.hmrc.ngrraldfrontend.models.components.NGRRadio | ||
import uk.gov.hmrc.ngrraldfrontend.models.components.NGRRadio.{ngrRadio, noButton, yesButton} | ||
import uk.gov.hmrc.ngrraldfrontend.models.forms.mappings.Mappings | ||
|
||
final case class DidYouGetMoneyFromLandlordForm(radio: String) | ||
|
||
object DidYouGetMoneyFromLandlordForm extends Mappings{ | ||
implicit val format: OFormat[DidYouGetMoneyFromLandlordForm] = Json.format[DidYouGetMoneyFromLandlordForm] | ||
|
||
private lazy val radioUnselectedError = "didYouGetMoneyFromLandlord.empty.error" | ||
private val moneyFromLandlordRadio = "didYouGetMoneyFromLandlord-radio-value" | ||
|
||
val messagesApi: MessagesApi = new DefaultMessagesApi() | ||
val lang: Lang = Lang.defaultLang | ||
val messages: Messages = MessagesImpl(lang, messagesApi) | ||
|
||
def unapply(didYouGetMoneyFromLandlordForm: DidYouGetMoneyFromLandlordForm): Option[String] = Some(didYouGetMoneyFromLandlordForm.radio) | ||
|
||
def form: Form[DidYouGetMoneyFromLandlordForm] = { | ||
Form( | ||
mapping( | ||
moneyFromLandlordRadio -> radioText(radioUnselectedError), | ||
)(DidYouGetMoneyFromLandlordForm.apply)(DidYouGetMoneyFromLandlordForm.unapply) | ||
) | ||
} | ||
|
||
def moneyLandlordRadio(implicit messages: Messages): NGRRadio = | ||
ngrRadio( | ||
radioName = moneyFromLandlordRadio, | ||
radioButtons = Seq( | ||
yesButton(), | ||
noButton() | ||
), | ||
ngrTitle = "didYouGetMoneyFromLandlord.title", | ||
ngrTitleClass = "govuk-fieldset__legend--l" | ||
) | ||
} |
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 |
---|---|---|
|
@@ -149,6 +149,9 @@ class Navigator @Inject()() { | |
case None => uk.gov.hmrc.ngrraldfrontend.controllers.routes.CheckRentFreePeriodController.show(NormalMode) | ||
} | ||
case RentFreePeriodPage => _ => uk.gov.hmrc.ngrraldfrontend.controllers.routes.RentDatesAgreeStartController.show(NormalMode) | ||
case ConfirmBreakClausePage => _ => uk.gov.hmrc.ngrraldfrontend.controllers.routes.LandlordController.show(NormalMode) //TODO This needs to be amended when the journey is completed | ||
case DidYouGetMoneyFromLandlordPage => _ => uk.gov.hmrc.ngrraldfrontend.controllers.routes.LandlordController.show(NormalMode) //TODO This needs to be amended when the journey is completed | ||
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. Please link your previous page |
||
|
||
case DoYouPayExtraForParkingSpacesPage => answers => | ||
answers.get(DoYouPayExtraForParkingSpacesPage) match { | ||
case Some(value) => value match { | ||
|
27 changes: 27 additions & 0 deletions
27
app/uk/gov/hmrc/ngrraldfrontend/pages/DidYouGetMoneyFromLandlordPage.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 DidYouGetMoneyFromLandlordPage extends QuestionPage[Boolean] { | ||
|
||
override def toString: String = "confirmBreakClause" | ||
|
||
override def path: JsPath = JsPath \ toString | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
app/uk/gov/hmrc/ngrraldfrontend/views/DidYouGetMoneyFromLandlordView.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,46 @@ | ||
@* | ||
* 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.DidYouGetMoneyFromLandlordForm | ||
|
||
@this( | ||
layout: Layout, | ||
formHelper: FormWithCSRF, | ||
govukErrorSummary: GovukErrorSummary, | ||
govukRadios : GovukRadios, | ||
saveAndContinueButton: saveAndContinueButton | ||
) | ||
|
||
@(selectedPropertyAddress: String, form: Form[DidYouGetMoneyFromLandlordForm], ngrRadio: Radios, mode: Mode)(implicit request: RequestHeader, messages: Messages, appConfig: AppConfig) | ||
|
||
@layout(pageTitle = Some(messages("didYouGetMoneyFromLandlord.title")), showBackLink = true, fullWidth = false) { | ||
@formHelper(action = uk.gov.hmrc.ngrraldfrontend.controllers.routes.DidYouGetMoneyFromLandlordController.submit(mode), Symbol("autoComplete") -> "off") { | ||
@if(form.errors.nonEmpty) { | ||
@govukErrorSummary(ErrorSummaryViewModel(form)) | ||
} | ||
<span class="govuk-caption-m">@selectedPropertyAddress</span> | ||
@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
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.