App.SectionsHeaderComponent = Ember.Component.extend
  classNames: ['sections-switcher-container', 'main-section-header']
  sections: Ember.computed -> @store.peekAll('section')
  actions:
    setSection: (section)->
      if section and section is @get('active_section')
        # click on already active section
        #return @transitionTo('section', section.id)
        #return App.Router.router.transitionTo('section', section)
        return @get('targetObject').transitionToRoute('section', section)
      @$('dd').removeClass('active')
      @$("[data-section=#{if section then section.id else 'all'}]").addClass('active')
      @set('active_section', section)
  didInsertElement: ->
    @$('dd').removeClass('active')
    section = @get('active_section')
    @$("[data-section=#{if section then section.id else 'all'}]").addClass('active')
