diff --git a/app/assets/javascripts/sidebar.js b/app/assets/javascripts/sidebar.js index d06ab9afb..b31678f80 100644 --- a/app/assets/javascripts/sidebar.js +++ b/app/assets/javascripts/sidebar.js @@ -114,6 +114,33 @@ } } + // Make active current project/experiment/task + function activateCurrent() { + var sidebar = $('#slide-panel'); + var projectId = sidebar.data('current-project'); + var experimentId = sidebar.data('current-experiment'); + var taskId = sidebar.data('current-task'); + var currentPage = sidebar.data('page'); + var li; + + if (currentPage === 'project') { + li = sidebar.find('li[data-project-id="' + projectId + '"]'); + } else if (currentPage === 'experiment') { + li = sidebar.find('[data-experiment-id="' + experimentId + '"]'); + } else if (currentPage === 'canvas') { + li = sidebar.find('[data-experiment-id="' + experimentId + '"]'); + li.find('.task-tree-link') + .append('' + + ''); + } else if (currentPage === 'task') { + li = sidebar.find('[data-module-id="' + taskId + '"]'); + } + li.find('a:first').addClass('disabled'); + li.addClass('active'); + } + + activateCurrent(); + // Add triangle icons and titles to every parent node $('.tree li:has(ul)') .addClass('parent_li') diff --git a/app/assets/stylesheets/partials/_sidebar.scss b/app/assets/stylesheets/partials/_sidebar.scss index e726e143b..f3eed2ba0 100644 --- a/app/assets/stylesheets/partials/_sidebar.scss +++ b/app/assets/stylesheets/partials/_sidebar.scss @@ -68,6 +68,14 @@ $toggle-btn-size: 50px; #slide-panel { height: 100%; + .disabled { + opacity: 1; + } + + .fa-caret-right { + padding: 3px 5px; + } + .tree { margin-bottom: 0; opacity: 1; diff --git a/app/helpers/sidebar_helper.rb b/app/helpers/sidebar_helper.rb index 47952732d..eafb8f930 100644 --- a/app/helpers/sidebar_helper.rb +++ b/app/helpers/sidebar_helper.rb @@ -1,13 +1,4 @@ module SidebarHelper - - def currently_active?(my_module) - @my_module.present? and @my_module.id == my_module.id - end - - def is_canvas? - action_name == "canvas" - end - def project_action_to_link_to(project) case action_name when 'samples' diff --git a/app/models/experiment.rb b/app/models/experiment.rb index fec46ca43..6bd1ce1e1 100644 --- a/app/models/experiment.rb +++ b/app/models/experiment.rb @@ -19,7 +19,8 @@ class Experiment < ApplicationRecord optional: true has_many :my_modules, inverse_of: :experiment, dependent: :destroy - has_many :active_my_modules, -> { where(archived: false) }, + has_many :active_my_modules, + -> { where(archived: false).order(:workflow_order) }, class_name: 'MyModule' has_many :my_module_groups, inverse_of: :experiment, dependent: :destroy has_many :report_elements, inverse_of: :experiment, dependent: :destroy diff --git a/app/models/project.rb b/app/models/project.rb index 80a8d5777..5c7e6876a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -27,7 +27,7 @@ class Project < ApplicationRecord foreign_key: 'restored_by_id', class_name: 'User', optional: true - belongs_to :team, inverse_of: :projects, optional: true + belongs_to :team, inverse_of: :projects, touch: true, optional: true has_many :user_projects, inverse_of: :project has_many :users, through: :user_projects has_many :experiments, inverse_of: :project diff --git a/app/views/experiments/canvas.html.erb b/app/views/experiments/canvas.html.erb index 8d2a3bdad..a9c7d008f 100644 --- a/app/views/experiments/canvas.html.erb +++ b/app/views/experiments/canvas.html.erb @@ -1,5 +1,5 @@ <% provide(:head_title, t("experiments.canvas.head_title", project: h(@project.name)).html_safe) %> -<%= render partial: "shared/sidebar" %> +<%= render partial: "shared/sidebar", locals: { current_experiment: @experiment, page: 'canvas' } %> <%= render partial: "shared/secondary_navigation" %>