attr = DS.attr
App.EmployeeShift = DS.Model.extend
  start_from: attr('moment')
  end_on: attr('moment')
  description: attr('string')
  employee: DS.belongsTo 'employee', async: false
  supplier: DS.belongsTo 'supplier', async: false
  calendar_event: Ember.computed 'start_from', 'end_on', 'title', 'employee.color', ->
    id: @id
    title: @get('title')
    start: @get('start_from')
    end: @get('end_on')
    color: @get('employee.color')

  title: Ember.computed 'employee.name', 'description', ->
    if @get('description')
      [@get('employee.name'), @get('description')].join(' - ')
    else
      @get 'employee.name'
  calendar_event_for_employee: (->
    id: @id
    title: @get('title_for_employee')
    start: @get('start_from')
    end: @get('end_on')
    color: @get('employee.color')
  ).property('start_from', 'end_on', 'title_for_employee')
  title_for_employee: Ember.computed 'supplier.name', 'description', ->
    if @get('description')
      [@get('supplier.name'), @get('description')].join(' - ')
    else
      @get 'supplier.name'
