All the little details
This commit is contained in:
@@ -1,19 +1,3 @@
|
||||
App.EmployeesIndexController = Ember.ArrayController.extend
|
||||
needs: ['application']
|
||||
employees: (-> @get('model').sortBy('name')).property('model.@each.name')
|
||||
actions:
|
||||
newEmployee: ->
|
||||
employee = @store.createRecord('employee')
|
||||
@modal 'employee_edit',
|
||||
model: employee
|
||||
title_path: 'employee.modal.new_title'
|
||||
close: -> employee.deleteRecord()
|
||||
editEmployee: (employee)->
|
||||
@modal 'employee_edit',
|
||||
model: employee
|
||||
title_path: 'employee.modal.edit_title'
|
||||
close: -> employee.rollback()
|
||||
destroyEmployee: (employee)->
|
||||
@modal 'confirm',
|
||||
title: t('employee.destroy.modal.title', employee.serialize())
|
||||
ok: -> employee.destroyRecord()
|
||||
|
||||
@@ -1,2 +1,23 @@
|
||||
App.EmployeesRoute = Ember.Route.extend
|
||||
model: -> @store.all 'employee'
|
||||
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.rollback()
|
||||
destroyEmployee: (employee)->
|
||||
ac = @controllerFor('application')
|
||||
if ac.get('employee.id') isnt employee.id
|
||||
ac.modal 'confirm',
|
||||
title: t('employee.destroy.modal.title', employee.serialize())
|
||||
ok: -> employee.destroyRecord()
|
||||
else
|
||||
ac.modal 'alert',
|
||||
title: 'You cannot remove yourself'
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
.row: .small-12.columns
|
||||
h2=t 'models.employee'
|
||||
.display-row
|
||||
.display-label=t 'attributes.employee.name'
|
||||
.display-field= model.name
|
||||
.display-row
|
||||
.display-label=t 'attributes.employee.manager'
|
||||
.display-field= boolean model.manager
|
||||
.display-row
|
||||
.display-label=t 'attributes.employee.active'
|
||||
.display-field= boolean model.active
|
||||
.display-row
|
||||
.display-label=t 'attributes.employee.color'
|
||||
.display-field: span.current-color= colorbox model.color
|
||||
.page-actions
|
||||
.small-12.columns
|
||||
link-to 'employees' class="button"
|
||||
span=t 'models.plural.employee'
|
||||
a.edit-button{ action 'editEmployee' model}= t 'helpers.links.edit'
|
||||
@@ -0,0 +1,3 @@
|
||||
p=body
|
||||
hr
|
||||
button.modal-close{action "close"}= t 'confirm.cancel'
|
||||
@@ -4,7 +4,7 @@ p=t 'employee_shift.modal.body_header'
|
||||
.form-field= model.employee.name
|
||||
.form-row.description
|
||||
.form-label=t 'attributes.employee_shift.description'
|
||||
.form-field
|
||||
.form-field.full
|
||||
= input valueBinding="model.description"
|
||||
= errors model.errors.description
|
||||
hr
|
||||
|
||||
@@ -3,7 +3,7 @@ App.ScheduleView = Ember.View.extend
|
||||
didInsertElement: ->
|
||||
placeholder = @$('#schedule-placeholder')
|
||||
controller = @get('controller')
|
||||
events = controller.get('model').map (employee_shift)->employee_shift.get('calendar_event')
|
||||
events = controller.get('model').filter((employee_shift) -> employee_shift.get('employee.active') ).map( (employee_shift)->employee_shift.get('calendar_event') )
|
||||
placeholder.fullCalendar
|
||||
header:
|
||||
left: 'prev,next,today'
|
||||
|
||||
@@ -10,6 +10,13 @@ td.boolean
|
||||
.boolean-true
|
||||
@extend .fa
|
||||
@extend .fa-money
|
||||
.display-field
|
||||
.boolean-true
|
||||
@extend .fa, .fa-lg, .fa-check
|
||||
.boolean-false
|
||||
@extend .fa, .fa-lg, .fa-minus
|
||||
|
||||
|
||||
td.colorbox
|
||||
+table-fit
|
||||
.list-orders-container
|
||||
|
||||
@@ -16,7 +16,7 @@ $side-spacing: 0px
|
||||
cursor: move !important
|
||||
.text-alert
|
||||
color: $alert-color
|
||||
.text-danger
|
||||
.text-warning
|
||||
color: $warning-color
|
||||
input.dimension
|
||||
width: 52px
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
display: inline-block
|
||||
span
|
||||
display: inline-block
|
||||
.form-field
|
||||
.form-field, .display-field
|
||||
.current-color
|
||||
.colorbox-container
|
||||
padding: 4px
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
.page-actions
|
||||
+grid-row
|
||||
$button-margin: 8px
|
||||
margin-top: 15px
|
||||
.edit-button
|
||||
+button($bg: $warning-color)
|
||||
margin-left: $button-margin
|
||||
@@ -15,7 +15,7 @@ class ConfirmationsController < Devise::ConfirmationsController
|
||||
|
||||
def after_confirmation_path_for(resource_name, resource)
|
||||
case resource_name
|
||||
when :supplier then supplier_root_path(anchor: '/settings')
|
||||
when :employee then supplier_root_path(anchor: '/settings')
|
||||
else root_path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,11 @@ module Suppliers
|
||||
class EmployeeShiftsController < Suppliers::ApplicationController
|
||||
def index
|
||||
@employee_shifts = EmployeeShift.for_supplier(current_supplier, relevant_from: 1.week.ago)
|
||||
@employee_shifts.include_relation(:employee)
|
||||
# Only select shifts from currently linked and employees
|
||||
@employee_shifts.select! do |shift|
|
||||
current_supplier.employee_ids.include?(shift.employee.try(:id))
|
||||
end
|
||||
render json: @employee_shifts, each_serializer: Suppliers::EmployeeShiftSerializer
|
||||
end
|
||||
def create
|
||||
|
||||
@@ -18,10 +18,11 @@ module Suppliers
|
||||
# POST /employees
|
||||
# POST /employees.json
|
||||
def create
|
||||
@employee = Employee.new(employee_params)
|
||||
@employee = Employee.find_by_email(employee_params[:email]) if employee_params[:email].present?
|
||||
@employee ||= Employee.new(employee_params)
|
||||
|
||||
if @employee.save
|
||||
current_supplier.add_employee @employee
|
||||
current_supplier.add_employee @employee unless current_supplier.employee_ids.include? @employee.id # already linked
|
||||
render json: @employee, serializer: Suppliers::EmployeeSerializer, status: :created
|
||||
else
|
||||
render json: {errors: @employee.errors}, status: :unprocessable_entity
|
||||
@@ -47,8 +48,9 @@ module Suppliers
|
||||
# DELETE /employees/1.json
|
||||
def destroy
|
||||
@employee = Employee.find(params[:id])
|
||||
render json: {}, status: :forbidden unless @employee.supplier_id == current_supplier.id
|
||||
@employee.destroy
|
||||
render json: {}, status: :forbidden unless current_supplier.employee_ids.include?(@employee.id)
|
||||
head :forbidden and return if @employee == current_employee # do not remove self at the moment
|
||||
current_supplier.remove_employee @employee
|
||||
|
||||
respond_to do |format|
|
||||
format.json { head :no_content }
|
||||
|
||||
@@ -22,7 +22,7 @@ class Employee
|
||||
property :name
|
||||
#property :email
|
||||
|
||||
has_many :employee_shifts
|
||||
has_many :employee_shifts, dependent: :destroy
|
||||
view :by_email, key: :email
|
||||
|
||||
class << self
|
||||
|
||||
@@ -57,6 +57,13 @@ class SupplierEmployeesSettings
|
||||
end
|
||||
define_method(attribute){ value }
|
||||
end
|
||||
def public_send(m, *args)
|
||||
if ::Employee::DEFAULT_SETTINGS.has_key?(m.to_s)
|
||||
::Employee::DEFAULT_SETTINGS[m.to_s]
|
||||
else
|
||||
nil # this time we will raise on further invocation, since then there is something wrong
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(all_employees_settings, employee, settings = {})
|
||||
|
||||
Reference in New Issue
Block a user