@@ -117,9 +117,11 @@ class ShutterServiceController @Inject()(
117
117
step1Out = Step1Out (sf.serviceNames, env, status)
118
118
} yield status match {
119
119
case ShutterStatusValue .Shuttered => Redirect (appRoutes.ShutterServiceController .step2Get)
120
- .withSession(request.session + updateFlowState(request.session)(_.copy(step1 = Some (step1Out))))
120
+ .withSession(request.session + updateFlowState(request.session)(_.copy(step1 = Some (step1Out))))
121
121
case ShutterStatusValue .Unshuttered => Redirect (appRoutes.ShutterServiceController .step3Get)
122
- .withSession(request.session + updateFlowState(request.session)(_.copy(step1 = Some (step1Out) , step2 = Some (Step2Out (reason = " " , outageMessage = " " )))))
122
+ .withSession(request.session + updateFlowState(request.session)(_.copy( step1 = Some (step1Out)
123
+ , step2 = Some (Step2Out (reason = " " , outageMessage = " " , requiresOutageMessage = false ))
124
+ )))
123
125
}
124
126
).merge
125
127
}
@@ -160,10 +162,11 @@ class ShutterServiceController @Inject()(
160
162
)
161
163
step2f = fromSession(request.session).flatMap(_.step2) match {
162
164
case Some (step2Out) => Step2Form (
163
- reason = step2Out.reason
164
- , outageMessage = step2Out.outageMessage
165
+ reason = step2Out.reason
166
+ , outageMessage = step2Out.outageMessage
167
+ , requiresOutageMessage = step2Out.requiresOutageMessage
165
168
)
166
- case None => Step2Form (reason = " " , outageMessage = " " )
169
+ case None => Step2Form (reason = " " , outageMessage = " " , requiresOutageMessage = true )
167
170
}
168
171
html <- EitherT .right[Result ](showPage2(step2Form.fill(step2f), step1Out).map(Ok (_)))
169
172
} yield html
@@ -186,7 +189,7 @@ class ShutterServiceController @Inject()(
186
189
hasErrors = formWithErrors => EitherT .left(showPage2(formWithErrors, step1Out).map(BadRequest (_)))
187
190
, success = data => EitherT .pure[Future , Result ](data)
188
191
)
189
- step2Out = Step2Out (sf.reason, sf.outageMessage)
192
+ step2Out = Step2Out (sf.reason, sf.outageMessage, sf.requiresOutageMessage )
190
193
} yield Redirect (appRoutes.ShutterServiceController .step3Get)
191
194
.withSession(request.session + updateFlowState(request.session)(fs => fs.copy(step2 = Some (step2Out))))
192
195
).merge
@@ -200,9 +203,9 @@ class ShutterServiceController @Inject()(
200
203
// --------------------------------------------------------------------------
201
204
202
205
private def showPage3 (form3 : Form [Step3Form ], step1Out : Step1Out , step2Out : Step2Out )(implicit request : Request [Any ]): Html = {
203
- val back = if (step1Out.status == ShutterStatusValue .Shuttered )
204
- appRoutes.ShutterServiceController .step2Get
205
- else appRoutes.ShutterServiceController .step1Post
206
+ val back = if (step1Out.status == ShutterStatusValue .Shuttered )
207
+ appRoutes.ShutterServiceController .step2Get
208
+ else appRoutes.ShutterServiceController .step1Post
206
209
page3(form3, step1Out, step2Out, back)
207
210
}
208
211
@@ -306,19 +309,22 @@ object ShutterServiceController {
306
309
def step2Form (implicit messagesProvider : MessagesProvider ) =
307
310
Form (
308
311
Forms .mapping(
309
- " reason" -> Forms .text
310
- , " outageMessage" -> Forms .text
312
+ " reason" -> Forms .text
313
+ , " outageMessage" -> Forms .text
314
+ , " requiresOutageMessage" -> Forms .boolean
311
315
)(Step2Form .apply)(Step2Form .unapply)
312
316
)
313
317
314
318
case class Step2Form (
315
- reason : String
316
- , outageMessage : String
319
+ reason : String
320
+ , outageMessage : String
321
+ , requiresOutageMessage : Boolean
317
322
)
318
323
319
324
case class Step2Out (
320
- reason : String
321
- , outageMessage : String
325
+ reason : String
326
+ , outageMessage : String
327
+ , requiresOutageMessage : Boolean
322
328
)
323
329
324
330
private implicit val step2OutFormats =
0 commit comments