Permalink
Browse files

Updated the UI to look presentable and added comments to actions in the

controller.
  • Loading branch information...
1 parent 9aee1e1 commit 5a4a09c1f02ab4a1f15421fd91c730e724246905 @esseguin committed Mar 24, 2012
Showing with 96 additions and 14 deletions.
  1. +11 −0 app/controllers/Application.java
  2. +21 −14 app/views/index.scala.html
  3. +3 −0 app/views/main.scala.html
  4. +61 −0 public/stylesheets/main.css
@@ -15,12 +15,18 @@ public static Result index() {
return redirect(routes.Application.tasks());
}
+ /**
+ * Main view for viewing tasks. Renders all of the tasks.
+ */
public static Result tasks() {
return ok(
views.html.index.render(Task.all(), taskForm)
);
}
+ /**
+ * Adds a new task to the database based on the contents of taskForm.
+ */
public static Result newTask() {
Form<Task> filledForm = taskForm.bindFromRequest();
if(filledForm.hasErrors()) {
@@ -33,6 +39,11 @@ public static Result newTask() {
}
}
+ /**
+ * Deletes a task from the database.
+ *
+ * @param id The ID of the task to delete
+ */
public static Result deleteTask(Long id) {
Task.delete(id);
return redirect(routes.Application.tasks());
View
@@ -2,30 +2,37 @@
@import helper._
-@main("Todo list") {
-
- <h1>@tasks.size() task(s)</h1>
-
- <ul>
+@main("Todo List") {
+<h1>@(tasks.size() match {
+ case 0 =>
+ case 1 => "1 task"
+ case _ => tasks.size() + " tasks"
+ })</h1>
+
+<div id="container">
+ <div id="tasklist">
@for(task <- tasks) {
- <li>
- @task.label
+ <div class="task">
+ <div class="taskLabel">@task.label</div>
- @form(routes.Application.deleteTask(task.id)) {
+ @form(routes.Application.deleteTask(task.id), args ='class -> "deleteform") {
<input type="submit" value="Delete">
}
- </li>
+ </div>
}
- </ul>
+ </div>
<h2>Add a new task</h2>
- @form(routes.Application.newTask()) {
+ @form(routes.Application.newTask(), args = 'id -> "newTaskForm") {
- @inputText(taskForm("label"))
+ @inputText(
+ field = taskForm("label"),
+ args = '_label -> "Task Description", 'placeholder -> "Get milk"
+ )
<input type="submit" value="Create">
}
-
-}
+</div>
+}
@@ -10,6 +10,9 @@
<script src="@routes.Assets.at("javascripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
</head>
<body>
+ <header>
+ @title
+ </header>
@content
</body>
</html>
@@ -0,0 +1,61 @@
+body {
+ font-family: Helvetica, Arial;
+ position: relative;
+ text-align: center;
+}
+
+header {
+ color: #FFFFE5;
+ background: #000033;
+ height: 50px;
+ font-size: 32px;
+ padding-top: 10px;
+ vertical-align: bottom;
+}
+
+div#container {
+ margin: 0px auto;
+ width: 500px;
+}
+
+#newTaskForm dd,dt {
+ display: inline-block;
+}
+
+#newTaskForm dd.info {
+ display: none;
+}
+
+div#tasklist .taskLabel,.deleteform{
+ padding-top: 8px;
+ padding-bottom: 8px;
+ line-height:100%;
+}
+
+div#tasklist .taskLabel {
+ display: inline;
+ float: left;
+ text-align: left;
+ padding-left: 10px;
+ width: 85%;
+ font-size: 20px;
+}
+
+div#tasklist div.task:nth-child(odd) {
+ background: #FFEE88;
+}
+div#tasklist div.task:nth-child(even) {
+ background: #FFFFAA;
+}
+
+.task {
+ overflow: auto;
+}
+
+.deleteform {
+ margin: 0;
+ padding: auto;
+ float: right;
+ display: inline;
+ overflow:hidden;
+}

0 comments on commit 5a4a09c

Please sign in to comment.