mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-05 22:44:22 +08:00
clear tables from report [fixes SCI-247] again
This commit is contained in:
parent
9ceea255b2
commit
111cb81d08
1 changed files with 11 additions and 0 deletions
|
@ -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'] != 1
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue