import Ember from 'ember'
export default Ember.Controller.extend
  is_manager: Ember.computed 'model.manager_ids', ->
    return false unless manager_ids = @get('model.manager_ids')
    return false unless user_id = @get('globals.current_user.id')
    manager_ids.includes user_id
  projects_for_user: Ember.computed "model.[]", "model.@each.users.[]", ->
    user_id = localStorage.getItem('user_id')
    projects = @get('sorted_projects')
    return projects if @get('is_manager') # Do not filter, sorry, managers have to see all the projects
    projects.filter (project)->
      project.get('users').mapBy('id').includes user_id
  #sorted_projects: Ember.computed 'projects.@each.name', -> @get('projects').sortBy('name')
  projectSorting: ["name:asc"]
  sorted_projects: Ember.computed.sort("model", "projectSorting")
