Basic fullcalendar integration
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
module Suppliers
|
||||
class EmployeeShiftsController < Suppliers::ApplicationController
|
||||
def index
|
||||
render json: current_supplier.employee_shifts, each_serializer: Suppliers::EmployeeShiftSerializer
|
||||
end
|
||||
def create
|
||||
@employee_shift.supplier = current_supplier
|
||||
@employee_shift.save
|
||||
render json: @employee_shift, serializer: Suppliers::EmployeeShiftSerializer
|
||||
end
|
||||
|
||||
def update
|
||||
@employee_shift.update employee_shift_params
|
||||
render json: @employee_shift, serializer: Suppliers::EmployeeShiftSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def employee_shift_params
|
||||
params.require(:employee_shift).permit(:start_on, :end_on, :employee_id)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -32,7 +32,8 @@ module Suppliers
|
||||
# PUT /employees/1.json
|
||||
def update
|
||||
@employee = Employee.find(params[:id])
|
||||
render json: {}, status: 404 unless @employee.supplier_id == current_supplier.id
|
||||
render json: {}, status: 404 unless current_supplier.employee_ids.include?(@employee.id)
|
||||
current_supplier.settings_for(@employee).update!(employee_params)
|
||||
respond_to do |format|
|
||||
if @employee.update_attributes(employee_params)
|
||||
format.json { head :no_content }
|
||||
@@ -57,7 +58,7 @@ module Suppliers
|
||||
private
|
||||
|
||||
def employee_params
|
||||
params.require(:employee).permit(:name, :email)
|
||||
params.require(:employee).permit(:name, :email, :active, :manager, :color)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user