Merge pull request #127 from ZmagoD/zd_SCI_247_again

Table from step stays in report, although it is deleted from step.
This commit is contained in:
Zmago Devetak 2016-09-02 15:59:17 +02:00 committed by GitHub
commit fb6bc31bec

View file

@ -511,10 +511,21 @@ class StepsController < ApplicationController
# In case of step model you can delete checkboxes, assets or tables.
def destroy_attributes(params)
update_params = {}
delete_step_tables(params)
extract_destroy_params(params, update_params)
@step.update_attributes(update_params) unless update_params.empty?
end
# Delete the step table
def delete_step_tables(params)
return unless params[:tables_attributes].present?
params[:tables_attributes].each do |table|
next unless table.second['_destroy']
table_to_destroy = Table.find_by(id: table.second['id'])
table_to_destroy.report_elements.destroy_all
end
end
# Checks if hash contains destroy parameter '_destroy' and returns
# boolean value.
def has_destroy_params(params)