All the little details
This commit is contained in:
@@ -1,19 +1,3 @@
|
|||||||
App.EmployeesIndexController = Ember.ArrayController.extend
|
App.EmployeesIndexController = Ember.ArrayController.extend
|
||||||
needs: ['application']
|
needs: ['application']
|
||||||
employees: (-> @get('model').sortBy('name')).property('model.@each.name')
|
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
|
App.EmployeesRoute = Ember.Route.extend
|
||||||
model: -> @store.all 'employee'
|
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-field= model.employee.name
|
||||||
.form-row.description
|
.form-row.description
|
||||||
.form-label=t 'attributes.employee_shift.description'
|
.form-label=t 'attributes.employee_shift.description'
|
||||||
.form-field
|
.form-field.full
|
||||||
= input valueBinding="model.description"
|
= input valueBinding="model.description"
|
||||||
= errors model.errors.description
|
= errors model.errors.description
|
||||||
hr
|
hr
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ App.ScheduleView = Ember.View.extend
|
|||||||
didInsertElement: ->
|
didInsertElement: ->
|
||||||
placeholder = @$('#schedule-placeholder')
|
placeholder = @$('#schedule-placeholder')
|
||||||
controller = @get('controller')
|
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
|
placeholder.fullCalendar
|
||||||
header:
|
header:
|
||||||
left: 'prev,next,today'
|
left: 'prev,next,today'
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ td.boolean
|
|||||||
.boolean-true
|
.boolean-true
|
||||||
@extend .fa
|
@extend .fa
|
||||||
@extend .fa-money
|
@extend .fa-money
|
||||||
|
.display-field
|
||||||
|
.boolean-true
|
||||||
|
@extend .fa, .fa-lg, .fa-check
|
||||||
|
.boolean-false
|
||||||
|
@extend .fa, .fa-lg, .fa-minus
|
||||||
|
|
||||||
|
|
||||||
td.colorbox
|
td.colorbox
|
||||||
+table-fit
|
+table-fit
|
||||||
.list-orders-container
|
.list-orders-container
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ $side-spacing: 0px
|
|||||||
cursor: move !important
|
cursor: move !important
|
||||||
.text-alert
|
.text-alert
|
||||||
color: $alert-color
|
color: $alert-color
|
||||||
.text-danger
|
.text-warning
|
||||||
color: $warning-color
|
color: $warning-color
|
||||||
input.dimension
|
input.dimension
|
||||||
width: 52px
|
width: 52px
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
display: inline-block
|
display: inline-block
|
||||||
span
|
span
|
||||||
display: inline-block
|
display: inline-block
|
||||||
.form-field
|
.form-field, .display-field
|
||||||
.current-color
|
.current-color
|
||||||
.colorbox-container
|
.colorbox-container
|
||||||
padding: 4px
|
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)
|
def after_confirmation_path_for(resource_name, resource)
|
||||||
case resource_name
|
case resource_name
|
||||||
when :supplier then supplier_root_path(anchor: '/settings')
|
when :employee then supplier_root_path(anchor: '/settings')
|
||||||
else root_path
|
else root_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,11 @@ module Suppliers
|
|||||||
class EmployeeShiftsController < Suppliers::ApplicationController
|
class EmployeeShiftsController < Suppliers::ApplicationController
|
||||||
def index
|
def index
|
||||||
@employee_shifts = EmployeeShift.for_supplier(current_supplier, relevant_from: 1.week.ago)
|
@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
|
render json: @employee_shifts, each_serializer: Suppliers::EmployeeShiftSerializer
|
||||||
end
|
end
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -18,10 +18,11 @@ module Suppliers
|
|||||||
# POST /employees
|
# POST /employees
|
||||||
# POST /employees.json
|
# POST /employees.json
|
||||||
def create
|
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
|
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
|
render json: @employee, serializer: Suppliers::EmployeeSerializer, status: :created
|
||||||
else
|
else
|
||||||
render json: {errors: @employee.errors}, status: :unprocessable_entity
|
render json: {errors: @employee.errors}, status: :unprocessable_entity
|
||||||
@@ -47,8 +48,9 @@ module Suppliers
|
|||||||
# DELETE /employees/1.json
|
# DELETE /employees/1.json
|
||||||
def destroy
|
def destroy
|
||||||
@employee = Employee.find(params[:id])
|
@employee = Employee.find(params[:id])
|
||||||
render json: {}, status: :forbidden unless @employee.supplier_id == current_supplier.id
|
render json: {}, status: :forbidden unless current_supplier.employee_ids.include?(@employee.id)
|
||||||
@employee.destroy
|
head :forbidden and return if @employee == current_employee # do not remove self at the moment
|
||||||
|
current_supplier.remove_employee @employee
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class Employee
|
|||||||
property :name
|
property :name
|
||||||
#property :email
|
#property :email
|
||||||
|
|
||||||
has_many :employee_shifts
|
has_many :employee_shifts, dependent: :destroy
|
||||||
view :by_email, key: :email
|
view :by_email, key: :email
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
|||||||
@@ -57,6 +57,13 @@ class SupplierEmployeesSettings
|
|||||||
end
|
end
|
||||||
define_method(attribute){ value }
|
define_method(attribute){ value }
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def initialize(all_employees_settings, employee, settings = {})
|
def initialize(all_employees_settings, employee, settings = {})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
nl:
|
nl:
|
||||||
supplier:
|
supplier:
|
||||||
confirm:
|
confirm:
|
||||||
cancel: Nee
|
cancel: Sluit
|
||||||
confirm: Ja
|
confirm: Ja
|
||||||
general:
|
general:
|
||||||
destroy:
|
destroy:
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ ALLOWED_LOCALES = /nl|be|de|fr|en/
|
|||||||
Qwaiter::Application.routes.draw do
|
Qwaiter::Application.routes.draw do
|
||||||
devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
|
devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
|
||||||
#devise_for :suppliers, controllers: { confirmations: 'confirmations', registrations: 'registrations' }
|
#devise_for :suppliers, controllers: { confirmations: 'confirmations', registrations: 'registrations' }
|
||||||
devise_for :employees
|
devise_for :employees, controllers: { confirmations: 'confirmations', registrations: 'registrations' }
|
||||||
devise_for :administrators
|
devise_for :administrators
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
resources :users do
|
resources :users do
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ describe Employee do
|
|||||||
employee.enrich_with_settings supplier.settings_for(employee)
|
employee.enrich_with_settings supplier.settings_for(employee)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'responds to defaults without full initialization (yes this test is needed)' do
|
||||||
|
Employee.new.manager?.should be false
|
||||||
|
end
|
||||||
|
|
||||||
it 'responds to defaults' do
|
it 'responds to defaults' do
|
||||||
employee.manager?.should be false
|
employee.manager?.should be false
|
||||||
employee.active?.should be true
|
employee.active?.should be true
|
||||||
|
|||||||
Reference in New Issue
Block a user