Qsupplier.App.SectionTabHeaderView = Ember.View.extend DragNDrop.Droppable,
  templateName: 'section_tab_header'
  classNames: ['section-tab-header']
  classNameBindings: ['section_header_class', 'controller.controllers.application.isDragging:table-dragging', 'section_active']
  click: (e)->
    @get('controller').transitionToRoute 'section', @get('context.id')

  section_header_class: (-> "section-tab-header-#{@get('context.id')}").property()
  dragEntered: (view)->
    @$().addClass('table-hover')
    return false
    # Changing the route for now is too difficult. Just do a move
    #if view.constructor.toString().match(/SectionTableView$/)
      #@get('controller').transitionToRoute 'section', @get('content')
  dragLeft: -> @$().removeClass('table-hover')
  dropped: (view)->
    if view.constructor.toString().match(/SectionTableView$/)
      table = view.get('content')
      table.set 'section', @content
      #table.get('transaction').commit()
      table.save()
  didInsertElement: ->
    @$el = $ @get('element')

  section_active: (->
    current_section = @get('controller.controllers.section.content.id')
    view_section = @get('context.id')
    if current_section == view_section then 'active' else ''
  ).property('controller.controllers.section.content.id')
