mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-08 00:23:01 +08:00
e8b952f4fd
This reverts commit 78d41d10a6
.
63 lines
1.9 KiB
Ruby
63 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Breadcrumbs
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
def set_breadcrumbs_items
|
|
my_module = @my_module
|
|
experiment = my_module&.experiment || @experiment
|
|
project = experiment&.project || @project
|
|
current_folder = project&.project_folder || @current_folder
|
|
@breadcrumbs_items = []
|
|
|
|
folders = helpers.tree_ordered_parent_folders(current_folder)
|
|
|
|
@breadcrumbs_items.push({
|
|
label: t('projects.index.breadcrumbs_root'),
|
|
url: projects_path
|
|
})
|
|
|
|
folders&.each do |project_folder|
|
|
@breadcrumbs_items.push({
|
|
label: project_folder.name,
|
|
url: project_folder_path(project_folder)
|
|
})
|
|
end
|
|
|
|
include_project(project) if project
|
|
|
|
include_experiment(experiment) if experiment
|
|
|
|
include_my_module(my_module) if my_module
|
|
|
|
@breadcrumbs_items
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def include_project(project)
|
|
@breadcrumbs_items.push({
|
|
label: project.name,
|
|
url: project_path(project),
|
|
archived: project.archived?
|
|
})
|
|
end
|
|
|
|
def include_experiment(experiment)
|
|
@breadcrumbs_items.push({
|
|
label: experiment.name,
|
|
url: my_modules_experiment_path(experiment),
|
|
archived: experiment.archived?
|
|
})
|
|
end
|
|
|
|
def include_my_module(my_module)
|
|
@breadcrumbs_items.push({
|
|
label: my_module.name,
|
|
url: my_module_path(my_module),
|
|
archived: my_module.archived?
|
|
})
|
|
end
|
|
end
|