diff --git a/app/assets/javascripts/reports/new.js b/app/assets/javascripts/reports/new.js index e1f16c1a5..67289090b 100644 --- a/app/assets/javascripts/reports/new.js +++ b/app/assets/javascripts/reports/new.js @@ -1020,15 +1020,16 @@ function reportHandsonTableConverter() { }); // Project content - reportData.project_content = { experiments: {}, repositories: [] }; + reportData.project_content = { experiments: [], tasks: {}, repositories: [] }; $.each($('.project-contents-container .experiment-element'), function(i, experiment) { let expCheckbox = $(experiment).find('.report-experiment-checkbox'); if (!expCheckbox.prop('checked') && !expCheckbox.prop('indeterminate')) return; let experimentId = $(experiment).find('.report-experiment-checkbox').val(); - reportData.project_content.experiments[experimentId] = []; + reportData.project_content.tasks[experimentId] = []; + reportData.project_content.experiments.push(experimentId); $.each($(experiment).find('.report-my-module-checkbox:checked'), function(j, myModule) { - reportData.project_content.experiments[experimentId].push(parseInt(myModule.value, 10)); + reportData.project_content.tasks[experimentId].push(parseInt(myModule.value, 10)); }); }); $.each($('.task-contents-container .repositories-contents .sci-checkbox:checked'), function(i, e) { diff --git a/app/models/report.rb b/app/models/report.rb index 3ec07e657..fcbfdd847 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -105,11 +105,13 @@ class Report < ApplicationRecord def self.generate_whole_project_report(project, current_user, current_team) # report_contents = gen_element_content(project, Extends::EXPORT_ALL_PROJECT_ELEMENTS) content = { - 'experiments' => {}, + 'experiments' => [], + 'tasks' => {}, 'repositories' => Repository.accessible_by_teams(project.team).pluck(:id) } project.experiments.includes(:my_modules).each do |experiment| - content['experiments'][experiment.id] = experiment.my_modules.pluck(:id) + content['experiments'].push(experiment.id) + content['tasks'][experiment.id] = experiment.my_modules.pluck(:id) end report = Report.new diff --git a/app/services/report_actions/report_content.rb b/app/services/report_actions/report_content.rb index 488ecdc62..22c7bcc0c 100644 --- a/app/services/report_actions/report_content.rb +++ b/app/services/report_actions/report_content.rb @@ -51,8 +51,8 @@ module ReportActions private def generate_content - @content['experiments'].each do |exp_id, my_modules| - generate_experiment_content(exp_id, my_modules) + @content['experiments'].each do |exp_id| + generate_experiment_content(exp_id, @content['tasks'][exp_id]) end end