23 lines
846 B
CoffeeScript
23 lines
846 B
CoffeeScript
App.EmployeeActionsMixin = Ember.Mixin.create
|
|
actions:
|
|
newEmployee: ->
|
|
employee = @store.createRecord('employee')
|
|
@get('controller').modal 'employee_edit',
|
|
model: employee
|
|
title_path: 'employee.modal.new_title'
|
|
close: -> employee.deleteRecord()
|
|
editEmployee: (employee)->
|
|
@get('controller').modal 'employee_edit',
|
|
model: employee
|
|
title_path: 'employee.modal.edit_title'
|
|
close: -> employee.rollbackAttributes()
|
|
destroyEmployee: (employee)->
|
|
ac = @controllerFor('application')
|
|
if @get('globals.current_employee.id') isnt employee.id
|
|
ac.modal 'confirm',
|
|
title: t('employee.destroy.modal.title', employee.toJSON())
|
|
ok: -> employee.destroyRecord()
|
|
else
|
|
ac.modal 'alert',
|
|
title: 'You cannot remove yourself'
|