Files
mozo-backend/app/controllers/suppliers/section_elements_controller.rb
T

37 lines
1.1 KiB
Ruby

module Suppliers
class SectionElementsController < Suppliers::ApplicationController
def index
@section_elements = SectionElement.for_supplier(current_supplier)
render json: @section_elements, each_serializer: Suppliers::SectionElementSerializer
end
def create
@section_element.supplier = current_supplier
if @section_element.save
render json: @section_element, serializer: Suppliers::SectionElementSerializer
else
render json: {errors: @section.errors}, status: :unprocessable_entity
end
end
def update
if @section_element.update_attributes section_element_params
render json: @section_element, serializer: Suppliers::SectionElementSerializer
else
render json: {errors: @section.errors}, status: :unprocessable_entity
end
end
def destroy
@section_element.destroy()
head :ok
end
private
def section_element_params
params.require(:section_element).permit %i[name svg dpm box_width box_height position_x position_y rotation svg_element_id section_id]
end
end
end