From de24f5b788c1ae6307eb360877ea3ce61c8f7a6a Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Thu, 5 Feb 2015 20:37:05 +0100 Subject: Implement flash messages --- app/controllers/Application.scala | 9 +++++---- app/views/fragments/flashBanner.scala.html | 13 ++++++++++++ app/views/pages/ebeHomepage.scala.html | 2 ++ app/views/pages/pepalHomepage.scala.html | 2 ++ app/views/templates/ebe.scala.html | 2 +- app/views/templates/main.scala.html | 4 +++- app/views/templates/pepal.scala.html | 2 +- public/stylesheets/main.css | 32 ++++++++++++++++++++++++++++++ 8 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 app/views/fragments/flashBanner.scala.html diff --git a/app/controllers/Application.scala b/app/controllers/Application.scala index 3380e38..12375df 100644 --- a/app/controllers/Application.scala +++ b/app/controllers/Application.scala @@ -7,15 +7,16 @@ import play.api.mvc._ object Application extends Controller { def index = Action { - Ok(views.html.pages.index("Your new application is ready.")) + Redirect("/ebe").flashing("warning" -> "hey") + //Ok(views.html.pages.index("Your new application is ready.")) } - def ebe = Action { + def ebe = Action { implicit request => Ok(views.html.pages.ebeHomepage()) } - def pepal = Action { + def pepal = Action { implicit request => Ok(views.html.pages.pepalHomepage()) } -} \ No newline at end of file +} diff --git a/app/views/fragments/flashBanner.scala.html b/app/views/fragments/flashBanner.scala.html new file mode 100644 index 0000000..41766f9 --- /dev/null +++ b/app/views/fragments/flashBanner.scala.html @@ -0,0 +1,13 @@ +@()(implicit flash:Flash) + +@displayFlash(flashType: String) = { + @for(message <- flash.get(flashType)) { +
+ @message +
+ } +} + +@for(flashType <- List("success", "info", "warning", "error")) { + @displayFlash(flashType) +} diff --git a/app/views/pages/ebeHomepage.scala.html b/app/views/pages/ebeHomepage.scala.html index bf11462..da1fb08 100644 --- a/app/views/pages/ebeHomepage.scala.html +++ b/app/views/pages/ebeHomepage.scala.html @@ -1,3 +1,5 @@ +@()(implicit flash: Flash) + @templates.ebe("eBé") {
diff --git a/app/views/pages/pepalHomepage.scala.html b/app/views/pages/pepalHomepage.scala.html index 6eb7070..b4a8e9c 100644 --- a/app/views/pages/pepalHomepage.scala.html +++ b/app/views/pages/pepalHomepage.scala.html @@ -1,3 +1,5 @@ +@()(implicit flash: Flash) + @templates.pepal("PéPal") {
diff --git a/app/views/templates/ebe.scala.html b/app/views/templates/ebe.scala.html index dbc1a88..2bab310 100644 --- a/app/views/templates/ebe.scala.html +++ b/app/views/templates/ebe.scala.html @@ -1,3 +1,3 @@ -@(title: String)(content: Html) +@(title: String)(content: Html)(implicit flash: Flash) @templates.main{@fragments.ebeLogo()}{@fragments.ebeSlogan()}(title)(content) diff --git a/app/views/templates/main.scala.html b/app/views/templates/main.scala.html index dadfc03..278b205 100644 --- a/app/views/templates/main.scala.html +++ b/app/views/templates/main.scala.html @@ -1,4 +1,4 @@ -@(logo: Html)(slogan: Html)(title: String)(content: Html) +@(logo: Html)(slogan: Html)(title: String)(content: Html)(implicit flash: Flash) @@ -50,6 +50,8 @@
+
@fragments.flashBanner()
+
@content