Files
mozo-backend/app/assets/javascripts/supplier/app/mixins/employee-actions-mixin.js.coffee
T
2015-09-21 18:25:37 +02:00

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'