From 44a17dc01465e745d5d716d572e253b64f8a6c29 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Mon, 10 May 2021 15:16:28 +0200 Subject: [PATCH] Fix ordering tasks in report and wizard [SCI-5706] --- app/assets/javascripts/reports/new.js | 3 ++- app/controllers/reports_controller.rb | 4 ++-- app/views/reports/wizard/_project_contents.html.erb | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/reports/new.js b/app/assets/javascripts/reports/new.js index 372ab71e5..2cedf7882 100644 --- a/app/assets/javascripts/reports/new.js +++ b/app/assets/javascripts/reports/new.js @@ -1019,7 +1019,7 @@ function reportHandsonTableConverter() { let experimentId = $(experiment).find('.report-experiment-checkbox').val(); reportData.project_content.experiments[experimentId] = []; $.each($(experiment).find('.report-my-module-checkbox:checked'), function(j, myModule) { - reportData.project_content.experiments[experimentId].push(myModule.value); + reportData.project_content.experiments[experimentId].push(parseInt(myModule.value, 10)); }); }); $.each($('.task-contents-container .repositories-contents .sci-checkbox:checked'), function(i, e) { @@ -1364,6 +1364,7 @@ function reportHandsonTableConverter() { }); $('#reportWizardEditWarning').modal('show'); + $('.experiment-contents').sortable(); initGenerateButton(); initReportWizard(); diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index c176d5963..5fe9054e1 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -115,8 +115,8 @@ class ReportsController < ApplicationController @report.settings = Report::DEFAULT_SETTINGS if @report.settings.blank? @project_contents = { - experiments: @report.report_elements.experiment.pluck(:experiment_id), - my_modules: @report.report_elements.my_module.pluck(:my_module_id), + experiments: @report.report_elements.order(:position).experiment.pluck(:experiment_id), + my_modules: @report.report_elements.order(:position).my_module.pluck(:my_module_id), repositories: @report.report_elements.my_module_repository.distinct(:repository_id).pluck(:repository_id) } render :new diff --git a/app/views/reports/wizard/_project_contents.html.erb b/app/views/reports/wizard/_project_contents.html.erb index cc40c096e..48888da63 100644 --- a/app/views/reports/wizard/_project_contents.html.erb +++ b/app/views/reports/wizard/_project_contents.html.erb @@ -1,5 +1,5 @@