40 lines
1.2 KiB
Ruby
40 lines
1.2 KiB
Ruby
module Suppliers
|
|
class SectionElementsController < Suppliers::ApplicationController
|
|
def index
|
|
@section_elements = SectionElement.for_supplier(current_supplier)
|
|
render json: @section_elements
|
|
end
|
|
|
|
def create
|
|
@section_element = SectionElement.new(section_element_params)
|
|
@section_element.supplier = current_supplier
|
|
if @section_element.save
|
|
render json: @section_element
|
|
else
|
|
render json: {errors: @section.errors}, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def update
|
|
@section_element = SectionElement.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
|
if @section_element.update_attributes section_element_params
|
|
render json: @section_element
|
|
else
|
|
render json: {errors: @section.errors}, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@section_element= SectionElement.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
|
@section_element.destroy
|
|
head :no_content
|
|
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
|