diff --git a/app/assets/javascripts/reports/new.js b/app/assets/javascripts/reports/new.js index 34502036c..b02ac0364 100644 --- a/app/assets/javascripts/reports/new.js +++ b/app/assets/javascripts/reports/new.js @@ -1063,6 +1063,11 @@ function reportHandsonTableConverter() { previousStep(); }); + $('.change-step').on('click', function() { + $(`[href="#new-report-step-${this.dataset.stepId}"]`).tab('show'); + $('.reports-new-footer').attr('data-step', this.dataset.stepId); + }); + $('.reports-new-body [href="#new-report-step-2"]').on('show.bs.tab', function() { var projectContents = $('#new-report-step-2').find('.project-contents'); if (projectContents.is(':empty')) { @@ -1161,6 +1166,7 @@ function reportHandsonTableConverter() { dropdownSelector.init('#projectSelector', { singleSelect: true, closeOnSelect: true, + noEmptyOption: true, selectAppearance: 'simple', onChange: function() { $('#new-report-step-2 .project-contents').empty(); diff --git a/app/assets/stylesheets/reports/new.scss b/app/assets/stylesheets/reports/new.scss index a68f013e1..420c4823e 100644 --- a/app/assets/stylesheets/reports/new.scss +++ b/app/assets/stylesheets/reports/new.scss @@ -86,19 +86,40 @@ white-space: nowrap; } + .change-step { + cursor: pointer; + height: 100%; + position: absolute; + top: 0; + width: 6em; + } &.wizard-step-1 { text-align: left; + .change-step { + left: -3em; + } + .name-wrapper { margin-left: calc(-50% + 2 * var(--wizard-step-dot-size)); } } + &.wizard-step-2 { + .change-step { + margin: 0 calc(50% - 3em); + } + } + &.wizard-step-3 { text-align: right; + .change-step { + right: -3em; + } + .name-wrapper { margin-right: calc(-50% + 2 * var(--wizard-step-dot-size)); } @@ -123,10 +144,15 @@ } } - .generate-button { + .generate-button, + .report-generate-actions-dropdown { display: none; } + .report-generate-actions-dropdown { + position: relative; + } + .next-button-container { flex-basis: 25%; margin-left: auto; @@ -197,6 +223,18 @@ display: initial; } + .report-generate-actions-dropdown { + display: inline-block; + + .dropdown-menu { + width: 250px; + + li { + padding: .5em 0; + } + } + } + .progress-step-1, .progress-step-2 { background: $brand-primary; diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 6740a9b78..9901bc7a7 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -63,7 +63,7 @@ class ReportsController < ApplicationController html: render_to_string( template: "reports/templates/#{template}/edit.html.erb", layout: 'reports/template_values_editor', - locals: { report: Report.new } + locals: { report: Report.find_by(id: params[:report_id]) || Report.new } ) } else @@ -108,11 +108,13 @@ class ReportsController < ApplicationController end def edit - # cleans all the deleted report - current_team_switch(@report.project.team) - @report.cleanup_report + @edit = true @templates = Extends::REPORT_TEMPLATES - render 'reports/new.html.erb' + @project_contents = { + experiments: @report.report_elements.where(type_of: 'experiment').pluck(:experiment_id), + my_modules: @report.report_elements.where(type_of: 'my_module').pluck(:my_module_id) + } + render :new end # Updating existing report from the _save modal of the new page @@ -325,7 +327,7 @@ class ReportsController < ApplicationController render json: { html: render_to_string( partial: 'reports/wizard/project_contents.html.erb', - locals: { project: @project } + locals: { project: @project, report: nil} ) } end diff --git a/app/views/reports/new.html.erb b/app/views/reports/new.html.erb index 1e0fcb130..f27e30389 100644 --- a/app/views/reports/new.html.erb +++ b/app/views/reports/new.html.erb @@ -1,7 +1,7 @@