From 5a95cdd1be2b46a5b76a787b83f4aad1766f365f Mon Sep 17 00:00:00 2001 From: jimi Date: Wed, 9 Oct 2013 08:22:46 -0500 Subject: [PATCH] Setup task model and entry form Create basic task model Restructure application template Create task entry form --- app/controllers/Application.scala | 14 +++++++++++++- app/models/Task.scala | 11 +++++++++++ app/views/index.scala.html | 23 ++++++++++++++++++++--- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 app/models/Task.scala diff --git a/app/controllers/Application.scala b/app/controllers/Application.scala index e5adc2d..33d75e6 100644 --- a/app/controllers/Application.scala +++ b/app/controllers/Application.scala @@ -3,13 +3,25 @@ package controllers import play.api._ import play.api.mvc._ +import play.api.data._ +import play.api.data.Forms._ + +import models.Task + + object Application extends Controller { + val taskForm = Form( + "label" -> nonEmptyText + ) + def index = Action { Redirect(routes.Application.tasks) } - def tasks = TODO + def tasks = Action { + Ok(views.html.index(Task.all(), taskForm)) + } def newTask = TODO diff --git a/app/models/Task.scala b/app/models/Task.scala new file mode 100644 index 0000000..10e46fa --- /dev/null +++ b/app/models/Task.scala @@ -0,0 +1,11 @@ +package models + +case class Task(id:Long, label:String) + +object Task { + def all(): List[Task] = Nil + + def create(label:String) {} + + def delete(id:Long) {} +} \ No newline at end of file diff --git a/app/views/index.scala.html b/app/views/index.scala.html index d6a6b22..2468d9e 100644 --- a/app/views/index.scala.html +++ b/app/views/index.scala.html @@ -1,7 +1,24 @@ -@(message: String) +@(tasks:List[Task], taskForm:Form[String]) -@main("Welcome to Play") { +@import helper._ - @play20.welcome(message) +@main("Todo List") { + +

@tasks.size task(s)

+ +

Add a new task

+ @form(routes.Application.newTask) { + @inputText(taskForm("label")) + + } }