Permalink
Browse files

Added task+log view (work in progress)

  • Loading branch information...
1 parent 4f6e8a0 commit af816c257476c907152c733754124a7e5a5a79a9 @pboos committed Apr 30, 2012
Showing with 56 additions and 4 deletions.
  1. +21 −1 index.jade
  2. +35 −3 js/app.coffee
View
22 index.jade
@@ -44,6 +44,26 @@ html(lang="en")
button.btn(type='submit') {{button}}
a.register Register
+ script#task(type='text/x-handlebars-template')
+ h3 {{name}}
+ table.table
+ tbody
+ tr
+ td URL
+ td {{url}}
+ tr
+ td crontab
+ tc {{crontab}}
+ h4 Logs
+ table.table
+ thead
+ tr
+ th Name
+ th Date
+ th Code
+ th
+ tbody
+
script#tasks(type='text/x-handlebars-template')
a.btn.btn.create
i.icon-plus
@@ -77,7 +97,7 @@ html(lang="en")
button.btn(type='submit') Create
a.register Register
- script#task(type='text/x-handlebars-template')
+ script#task-line(type='text/x-handlebars-template')
td {{name}}
td {{url}}
td {{crontab}}
View
38 js/app.coffee
@@ -21,14 +21,16 @@ jQuery ->
@unbind()
@undelegateEvents()
- class TaskView extends Backbone.View
+ # Tasks
+
+ class TaskLineView extends Backbone.View
tagName: 'tr'
initialize: ->
_.bindAll @
@model.bind 'change', @render
@model.bind 'remove', @unrender
render: ->
- template = Handlebars.compile($("#task").html())
+ template = Handlebars.compile($("#task-line").html())
data =
name: @model.get 'name'
url: @model.get 'url'
@@ -37,8 +39,10 @@ jQuery ->
@
events:
'click .delete': 'remove'
+ 'click': 'open'
remove: -> @model.destroy()
unrender: => $(@el).remove()
+ open: -> app.navigate 'task/' + @model.get('id'), {trigger: true}
class TaskListView extends Backbone.View
initialize: ->
@@ -53,7 +57,7 @@ jQuery ->
template = Handlebars.compile($("#tasks").html())
$(@el).html(template({}))
@collection.forEach (item) ->
- itemView = new TaskView model: item
+ itemView = new TaskLineView model: item
$('tbody').append itemView.render().el
@
@@ -62,6 +66,19 @@ jQuery ->
createTask: ->
app.navigate 'task/create', {trigger: true}
+ # Task
+
+ class TaskView extends Backbone.View
+ render: ->
+ template = Handlebars.compile($("#task").html())
+ $(@el).html(template())
+
+ class LogListView extends Backbone.View
+
+ class LogItemView extends Backbone.View
+
+ # Create Task
+
class CreateTaskView extends Backbone.View
render: ->
template = Handlebars.compile($("#task-create").html())
@@ -78,6 +95,8 @@ jQuery ->
request.error (data) ->
alert JSON.parse(data.responseText).details.message
+ # Login
+
class LoginView extends Backbone.View
render: ->
template = Handlebars.compile($("#login").html())
@@ -100,6 +119,8 @@ jQuery ->
register: ->
app.navigate 'register', {trigger: true}
+ # Register
+
class RegisterView extends Backbone.View
render: ->
template = Handlebars.compile($("#login").html())
@@ -117,6 +138,8 @@ jQuery ->
request.error ->
alert 'error!'
+ # User badge
+
class UserBadgeView extends Backbone.View
el: $ 'ul.nav li.userbadge'
initialize: ->
@@ -146,6 +169,7 @@ jQuery ->
"logout": "logout"
"register": "register"
"task/create": "task_create"
+ "task/:id": "task"
initialize: ->
console.log 'init'
@@ -162,6 +186,14 @@ jQuery ->
if !isLoggedIn()
return app.navigate 'login', {trigger: true}
@appView.show new TaskListView
+ task: (id)->
+ if !isLoggedIn()
+ return app.navigate 'login', {trigger: true}
+
+ task = new Task {id: id}
+ task.fetch
+ success: ->
+ new TaskView model: task
task_create: ->
if !isLoggedIn()
return app.navigate 'login', {trigger: true}

0 comments on commit af816c2

Please sign in to comment.