37 lines
1.0 KiB
Ruby
37 lines
1.0 KiB
Ruby
module Suppliers
|
|
class SectionAreasController < Suppliers::ApplicationController
|
|
def index
|
|
@section_areas = SectionArea.for_supplier(current_supplier)
|
|
render json: @section_areas, each_serializer: Suppliers::SectionAreaSerializer
|
|
end
|
|
|
|
def create
|
|
@section_area.supplier = current_supplier
|
|
if @section_area.save
|
|
render json: @section_area, serializer: Suppliers::SectionAreaSerializer
|
|
else
|
|
render json: {errors: @section.errors}, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def update
|
|
if @section_area.update_attributes section_area_params
|
|
render json: @section_area, serializer: Suppliers::SectionAreaSerializer
|
|
else
|
|
render json: {errors: @section.errors}, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@section_area.destroy
|
|
head :ok
|
|
end
|
|
|
|
private
|
|
|
|
def section_area_params
|
|
params.require(:section_area).permit %i[title width height position_x position_y section_id rounded]
|
|
end
|
|
end
|
|
end
|