2022-04-29 18:29:42 +08:00
|
|
|
|
|
|
|
module StepComponents
|
|
|
|
class TablesController < StepOrderableElementsController
|
|
|
|
private
|
|
|
|
|
|
|
|
def create_step_element
|
|
|
|
@step.step_tables.create!(table:
|
|
|
|
Table.create!(
|
|
|
|
name: t('protocols.steps.table.default_name', position: @step.step_tables.length + 1),
|
2022-05-06 17:59:22 +08:00
|
|
|
contents: { data: Array.new(5, Array.new(5, '')) }.to_json,
|
2022-04-29 18:29:42 +08:00
|
|
|
created_by: current_user
|
|
|
|
))
|
|
|
|
end
|
|
|
|
|
2022-05-06 17:59:22 +08:00
|
|
|
def orderable_params
|
|
|
|
params.permit(:name, :contents)
|
2022-04-29 18:29:42 +08:00
|
|
|
end
|
2022-05-03 21:15:49 +08:00
|
|
|
|
|
|
|
def load_vars
|
|
|
|
@element = @step.tables.find_by(id: params[:id])
|
|
|
|
@orderable_element = @element.step_table.step_orderable_elements.find_by(step: @step)
|
|
|
|
return render_404 unless @element && @orderable_element
|
|
|
|
end
|
2022-04-29 18:29:42 +08:00
|
|
|
end
|
|
|
|
end
|