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")) + + } }