 routes : routes
 daterangepicker : DateRangePicker
 rangeslider : RangeSlider
+libs/utils : Utils
 ###
 
 class TaskOverviewView extends Backbone.Marionette.ItemView

    @ui.dateRangeInput.daterangepicker(
      locale:
        format: 'L'
      startDate: moment().subtract(3, 'months').format("L")
      endDate: moment().format("L")
      opens: "left"
    (start, end, label) =>
      @paintGraph()
    )
    return


  initializeRangeSlider : ->

    RangeSlider.create(@ui.rangeSliderInput[0],
      start: [0, 80]
      connect: true
      step: 1
      range:
        min: 0
        max: 100 #TODO: Find min/max in data
    )

    @ui.rangeSliderInput[0].noUiSlider.on('update', (values, handle) =>
      @ui.rangeSliderLabel1[0].innerHTML = "#{Math.round(+values[0])}h";
      @ui.rangeSliderLabel2[0].innerHTML = "#{Math.round((+values[0] + +values[1]) / 2)}h";
      @ui.rangeSliderLabel3[0].innerHTML = "#{Math.round(+values[1])}h";
      @paintGraphDebounced()
    )
    return


  paintGraphDebounced : ->

  buildNodes : (taskTypes, projects) ->

    svgUsers = @users.map( (user) =>
      if @doDrawUser(user)
        userName = user.firstName + " " + user.lastName
        workingHours = user.workingHours
        minMaxHours = @getMinMaxHours()
        color = @colorJet(128 - (workingHours - minMaxHours.min) * (128 / minMaxHours.max - minMaxHours.min) + 128)

        @quoted(userName) + " [id="+ @quoted(user.id) + ", shape=box, fillcolor=" + @quoted(color) + "]"
    ).join(";")

    svgTaskTypes = ""
