diff --git a/app/assets/javascripts/reports/new.js b/app/assets/javascripts/reports/new.js index 061e2589e..d8e24e01d 100644 --- a/app/assets/javascripts/reports/new.js +++ b/app/assets/javascripts/reports/new.js @@ -1,4 +1,4 @@ -/* globals animateSpinner GLOBAL_CONSTANTS */ +/* globals animateSpinner GLOBAL_CONSTANTS dropdownSelector */ var REPORT_CONTENT = '#report-content'; var ADD_CONTENTS_FORM_ID = '#add-contents-form'; @@ -990,5 +990,25 @@ function reportHandsonTableConverter() { }); } + function initDropdowns() { + dropdownSelector.init('#projectSelector', { + singleSelect: true, + closeOnSelect: true, + selectAppearance: 'simple', + onChange: function() { + $('.continue-button').attr('disabled', false); + } + }); + + dropdownSelector.init('#templateSelector', { + singleSelect: true, + closeOnSelect: true, + noEmptyOption: true, + selectAppearance: 'simple', + disableSearch: true + }); + } + initReportWizard(); + initDropdowns(); }()); diff --git a/app/assets/stylesheets/reports/new.scss b/app/assets/stylesheets/reports/new.scss index be889145a..c950347c4 100644 --- a/app/assets/stylesheets/reports/new.scss +++ b/app/assets/stylesheets/reports/new.scss @@ -203,6 +203,34 @@ } } } + + .project-selector-container { + background: $color-white; + box-shadow: $modal-shadow; + margin: 2em 20%; + padding: 1em 2em; + width: 60%; + + .description { + @include font-main; + } + + .project-selector, + .template-selector { + display: inline-block; + margin-bottom: 1em; + width: 100%; + + label { + @include font-small; + } + } + + #projectDescription { + height: 110px; + padding: .5em; + } + } } @media (max-width: 960px) { @@ -212,5 +240,10 @@ display: none; } } + + .project-selector-container { + margin: 2em 1em; + width: calc(100% - 2em); + } } } diff --git a/app/assets/stylesheets/shared/dropdown_selector.scss b/app/assets/stylesheets/shared/dropdown_selector.scss index e38f211df..8b365f7e3 100644 --- a/app/assets/stylesheets/shared/dropdown_selector.scss +++ b/app/assets/stylesheets/shared/dropdown_selector.scss @@ -12,7 +12,7 @@ .input-field { align-items: center; background: $color-white; - border: 1px solid $color-alto; + border: 1px solid $color-silver-chalice; border-radius: 4px; display: flex; flex-wrap: wrap; diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 4eda05a17..a91624940 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -25,7 +25,7 @@ class ReportsController < ApplicationController before_action :load_vars, only: %i(edit update) before_action :load_vars_nested, only: BEFORE_ACTION_METHODS - before_action :load_visible_projects, only: :visible_projects + before_action :load_visible_projects, only: :new before_action :load_available_repositories, only: %i(new edit available_repositories) @@ -49,6 +49,7 @@ class ReportsController < ApplicationController # Report grouped by modules def new + @templates = [['Scinote Template', 1]] end # Creating new report from the _save modal of the new page @@ -457,7 +458,6 @@ class ReportsController < ApplicationController private include StringUtility - VisibleProject = Struct.new(:path, :name) AvailableRepository = Struct.new(:id, :name) def load_vars @@ -477,13 +477,9 @@ class ReportsController < ApplicationController def load_visible_projects render_404 unless current_team - projects = Project.visible_from_user_by_name( - current_user, current_team, search_params[:q] - ).limit(Constants::SEARCH_LIMIT).select(:id, :name) - @visible_projects = projects.collect do |project| - VisibleProject.new(new_project_reports_path(project), - ellipsize(project.name, 50, 40)) - end + @visible_projects = Project.viewable_by_user( + current_user, current_team + ).select(:id, :name) end def load_available_repositories diff --git a/app/models/project.rb b/app/models/project.rb index 020063bb7..a386ab542 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -55,18 +55,6 @@ class Project < ApplicationRecord scope :templates, -> { where(template: true) } - def self.visible_from_user_by_name(user, team, name) - projects = where(team: team).distinct - if user.is_admin_of_team?(team) - projects.where('projects.archived IS FALSE AND projects.name ILIKE ?', "%#{name}%") - else - projects.joins(:user_projects) - .where('user_projects.user_id = ? OR projects.visibility = 1', user.id) - .where('projects.archived IS FALSE AND projects.name ILIKE ?', - "%#{name}%") - end - end - def self.search( user, include_archived, diff --git a/app/views/reports/new.html.erb b/app/views/reports/new.html.erb index fd0f9d5ec..a7f92c7b3 100644 --- a/app/views/reports/new.html.erb +++ b/app/views/reports/new.html.erb @@ -16,7 +16,7 @@