 
 class View.Worker extends Backbone.View
   tagName: 'li'
-  initialize: ->
-    @listenTo @model, 'change', @render
 
   render: ->
-    @$el.html "<p>#{@model.id}</p>"
-    if job = @model.get 'job'
-      jobList = $ '<ul>'
-      @$el.append jobList
-      new View.Job(model:job).render().$el.appendTo jobList
+    @$el.html "<p>#{@model.id}</p><ul></ul>"
     this
 
 class View.Flatware extends Backbone.View

    @listenTo @model.jobs, 'add', (job)->
      new View.Job(model: job).render().$el.appendTo '#waiting'

    @listenTo @model.jobs, 'change:worker', (job, worker)->
      unless worker
        new View.Job(model: job).render().$el.appendTo '#finished'

    @listenTo @model.workers, 'add', (job)->
      new View.Worker(model: job).render().$el.appendTo '#workers'

      {status, worker} = progress
      @workers.add(id: worker).get(worker).addStatus(status)

    # @on 'all', -> console.log arguments

class Job extends Backbone.Model
  defaults:
    status: 'waiting'
    dots: []

  initialize: ->
    @on 'change:worker', (_, worker)->
      if worker
        @trigger 'assigned', worker
      else
        @trigger 'completed'

  title: -> @id.match(/\/(.*)\./)[1].replace /_/g, ' '

