mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 21:21:50 +08:00
Revert "Revert "Improve breadcrumbs implementation [SCI-8087]""
This reverts commit 78d41d10a6
.
This commit is contained in:
parent
0cff2f4442
commit
e8b952f4fd
17 changed files with 238 additions and 19 deletions
3
app/assets/images/icon_small/navigate_next.svg
Normal file
3
app/assets/images/icon_small/navigate_next.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="6" height="11" viewBox="0 0 6 11" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0.7 10.6L0 9.9L4.6 5.3L0 0.7L0.7 0L6 5.3L0.7 10.6Z" fill="#98A2B3"/>
|
||||
</svg>
|
After Width: | Height: | Size: 180 B |
42
app/assets/stylesheets/navigation/breadcrumbs.scss
Normal file
42
app/assets/stylesheets/navigation/breadcrumbs.scss
Normal file
|
@ -0,0 +1,42 @@
|
|||
.sci--layout-navigation-breadcrumbs {
|
||||
--max-breadcrumbs-link-width: 11.25rem;
|
||||
align-items: center;
|
||||
column-gap: .875rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: .875rem 1.5rem .5rem;
|
||||
|
||||
.breadcrumbs-link {
|
||||
color: var(--sn-blue);
|
||||
display: inline-block;
|
||||
max-width: var(--max-breadcrumbs-link-width);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
&:last-child {
|
||||
color: var(--sn-grey);
|
||||
}
|
||||
}
|
||||
|
||||
.delimiter {
|
||||
padding-bottom: .25rem;
|
||||
}
|
||||
|
||||
.breadcrumbs-collapsed-container {
|
||||
color: var(--sn-blue);
|
||||
position: relative;
|
||||
|
||||
.show-breadcrumbs {
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
a {
|
||||
@include font-button;
|
||||
color: var(--sn-blue);
|
||||
}
|
||||
}
|
||||
}
|
63
app/controllers/concerns/breadcrumbs.rb
Normal file
63
app/controllers/concerns/breadcrumbs.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
# 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
|
|
@ -6,6 +6,7 @@ class ExperimentsController < ApplicationController
|
|||
include ActionView::Helpers::TextHelper
|
||||
include ApplicationHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
include Breadcrumbs
|
||||
|
||||
before_action :load_project, only: %i(new create archive_group restore_group)
|
||||
before_action :load_experiment, except: %i(new create archive_group restore_group)
|
||||
|
@ -18,6 +19,7 @@ class ExperimentsController < ApplicationController
|
|||
before_action :check_clone_permissions, only: %i(clone_modal clone)
|
||||
before_action :check_move_permissions, only: %i(move_modal move)
|
||||
before_action :set_inline_name_editing, only: %i(canvas table module_archive)
|
||||
before_action :set_breadcrumbs_items, only: %i(canvas table module_archive)
|
||||
|
||||
layout 'fluid'
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ class LabelTemplatesController < ApplicationController
|
|||
before_action :check_manage_permissions, only: %i(create duplicate set_default delete update)
|
||||
before_action :load_label_templates, only: %i(index datatable)
|
||||
before_action :load_label_template, only: %i(show set_default update template_tags)
|
||||
before_action :set_breadcrumbs_items, only: %i(index show)
|
||||
|
||||
layout 'fluid'
|
||||
|
||||
|
@ -186,4 +187,20 @@ class LabelTemplatesController < ApplicationController
|
|||
team: label_template.team,
|
||||
message_items: message_items)
|
||||
end
|
||||
|
||||
def set_breadcrumbs_items
|
||||
@breadcrumbs_items = []
|
||||
|
||||
@breadcrumbs_items.push({
|
||||
label: t('breadcrumbs.labels'),
|
||||
url: label_templates_path
|
||||
})
|
||||
|
||||
if @label_template
|
||||
@breadcrumbs_items.push({
|
||||
label: @label_template.name,
|
||||
url: label_template_path(@label_template)
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ class MyModulesController < ApplicationController
|
|||
include ActionView::Helpers::UrlHelper
|
||||
include ApplicationHelper
|
||||
include MyModulesHelper
|
||||
include Breadcrumbs
|
||||
|
||||
before_action :load_vars, except: %i(restore_group create new save_table_state)
|
||||
before_action :load_experiment, only: %i(create new)
|
||||
|
@ -19,6 +20,7 @@ class MyModulesController < ApplicationController
|
|||
before_action :check_update_state_permissions, only: :update_state
|
||||
before_action :set_inline_name_editing, only: %i(protocols results activities archive)
|
||||
before_action :load_experiment_my_modules, only: %i(protocols results activities archive)
|
||||
before_action :set_breadcrumbs_items, only: %i(results protocols activities)
|
||||
|
||||
layout 'fluid'.freeze
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ class ProjectsController < ApplicationController
|
|||
include ProjectsHelper
|
||||
include CardsViewHelper
|
||||
include ExperimentsHelper
|
||||
include Breadcrumbs
|
||||
|
||||
attr_reader :current_folder
|
||||
helper_method :current_folder
|
||||
|
@ -22,6 +23,7 @@ class ProjectsController < ApplicationController
|
|||
before_action :load_exp_sort_var, only: :show
|
||||
before_action :reset_invalid_view_state, only: %i(index cards show)
|
||||
before_action :set_folder_inline_name_editing, only: %i(index cards)
|
||||
before_action :set_breadcrumbs_items, only: %i(index show)
|
||||
|
||||
layout 'fluid'
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ class ProtocolsController < ApplicationController
|
|||
|
||||
before_action :set_importer, only: %i(load_from_file import)
|
||||
before_action :set_inline_name_editing, only: :show
|
||||
before_action :set_breadcrumbs_items, only: %i(index show)
|
||||
|
||||
layout 'fluid'
|
||||
|
||||
|
@ -1133,4 +1134,21 @@ class ProtocolsController < ApplicationController
|
|||
protocol: link_to(@protocol.name, protocol_url(@protocol)))
|
||||
)
|
||||
end
|
||||
|
||||
def set_breadcrumbs_items
|
||||
@breadcrumbs_items = []
|
||||
|
||||
@breadcrumbs_items.push({
|
||||
label: t('breadcrumbs.protocols'),
|
||||
url: protocols_path
|
||||
})
|
||||
|
||||
if @protocol
|
||||
@breadcrumbs_items.push({
|
||||
label: @protocol.name,
|
||||
url: protocol_path(@protocol),
|
||||
archived: @protocol.archived?
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,7 @@ class RepositoriesController < ApplicationController
|
|||
before_action :check_create_permissions, only: %i(create_modal create)
|
||||
before_action :check_copy_permissions, only: %i(copy_modal copy)
|
||||
before_action :set_inline_name_editing, only: %i(show)
|
||||
before_action :set_breadcrumbs_items, only: %i(index show)
|
||||
|
||||
layout 'fluid'
|
||||
|
||||
|
@ -525,4 +526,21 @@ class RepositoriesController < ApplicationController
|
|||
team: @repository.team,
|
||||
message_items: message_items)
|
||||
end
|
||||
|
||||
def set_breadcrumbs_items
|
||||
@breadcrumbs_items = []
|
||||
|
||||
@breadcrumbs_items.push({
|
||||
label: t('breadcrumbs.inventories'),
|
||||
url: repositories_path
|
||||
})
|
||||
|
||||
if @repository
|
||||
@breadcrumbs_items.push({
|
||||
label: @repository.name,
|
||||
url: repository_path(@repository),
|
||||
archived: @repository.archived?
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<div class="content-header sticky-header">
|
||||
<div id="breadcrumbsWrapper">
|
||||
<%= render partial: 'projects/index/breadcrumbs', locals: {target_folder: @experiment.project.project_folder, project: @experiment.project, experiment: @experiment} %>
|
||||
</div>
|
||||
<div class="title-row">
|
||||
<h1 class="experimnet-name" data-toggle="tooltip" data-placement="bottom" title="<%= @experiment.name %>">
|
||||
<% if @experiment.archived? %>
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<span style="display: none;" data-hook="application-body-html"></span>
|
||||
|
||||
<div class="sci--layout"
|
||||
data-breadcrumbs-collapsed="true"
|
||||
data-breadcrumbs-collapsed="<%= !@breadcrumbs_items.present? %>"
|
||||
data-navigator-collapsed="<%= !content_for?(:sidebar_title) || session[:navigator_collapsed] %>"
|
||||
data-navitgator-state-url="<%= navigator_state_navigations_path %>"
|
||||
data-left-navigation-collapsed=<%= !user_signed_in? %>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
%>
|
||||
<% end %>
|
||||
<%= render partial: 'shared/drag_n_drop_overlay' %>
|
||||
<%= render partial: 'shared/secondary_navigation', locals: { render_breadcrumbs: true, project: @experiment.project, experiment: @experiment } %>
|
||||
<%= render partial: 'shared/secondary_navigation', locals: { render_breadcrumbs: false, project: @experiment.project, experiment: @experiment } %>
|
||||
|
||||
<div class="content-pane my-modules-protocols-index" data-task-id="<%= @my_module.id %>">
|
||||
<div class="my-module-position-container">
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<div class="content-header sticky-header">
|
||||
<div id="breadcrumbsWrapper">
|
||||
<%= render partial: 'projects/index/breadcrumbs', locals: { target_folder: current_folder, folder_page: true } if current_folder %>
|
||||
</div>
|
||||
<div class="title-row">
|
||||
<% if current_folder&.name && @inline_editable_title_config.present? %>
|
||||
<h1 data-view-mode="active" class="projects-title">
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<div class="content-header sticky-header">
|
||||
<div id="breadcrumbsWrapper">
|
||||
<%= render partial: 'projects/index/breadcrumbs', locals: { target_folder: @project.project_folder } %>
|
||||
</div>
|
||||
<div class="title-row">
|
||||
<h1 class="project-name">
|
||||
<% if @project.archived? %>
|
||||
|
|
|
@ -5,14 +5,6 @@
|
|||
<% provide(:container_class, 'no-second-nav-container') %>
|
||||
<div class="content-pane protocols-show" >
|
||||
<div class="content-header">
|
||||
<div id="breadcrumbsWrapper">
|
||||
<div class="breadcrumbs-container protocol-breadcrumbs">
|
||||
<a href="<%= protocols_path %>" class="breadcrumbs-link">
|
||||
<%= t('sidebar.templates.protocol_templates') %>
|
||||
</a>
|
||||
<span class="delimiter">/</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="title-row">
|
||||
<h1>
|
||||
<% if @inline_editable_title_config.present? %>
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
<% if @breadcrumbs_items&.length %>
|
||||
<% @breadcrumbs_items.each { |item| item[:label] = "(A) #{item[:label]}" if item[:archived] }%>
|
||||
<% shortened = @breadcrumbs_items.length > 4 %>
|
||||
|
||||
<% if shortened %>
|
||||
<% first_breadcrumb_item = @breadcrumbs_items.shift
|
||||
last_breadcrumb_items = @breadcrumbs_items.pop(2) %>
|
||||
<%= link_to(first_breadcrumb_item[:label], first_breadcrumb_item[:url],
|
||||
class: "breadcrumbs-link",
|
||||
title: first_breadcrumb_item[:label]) %>
|
||||
<span class="delimiter">
|
||||
<%= image_tag "icon_small/navigate_next.svg",
|
||||
alt: "navigate next",
|
||||
class: "navigate_next" %>
|
||||
</span>
|
||||
<span class="breadcrumbs-collapsed-container">
|
||||
<span class="show-breadcrumbs" data-toggle="dropdown" title="<%= t('projects.index.breadcrumbs_collapsed') %>">
|
||||
•••
|
||||
<span class="caret pull-right"></span>
|
||||
</span>
|
||||
<ul class="dropdown-menu breadcrumbs-dropdown" role="menu">
|
||||
<% @breadcrumbs_items.each do |item| %>
|
||||
<li>
|
||||
<%= link_to(item[:label], item[:url]) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</span>
|
||||
<span class="delimiter">
|
||||
<%= image_tag "icon_small/navigate_next.svg",
|
||||
alt: "navigate next",
|
||||
class: "navigate_next" %>
|
||||
</span>
|
||||
<% item = last_breadcrumb_items.first %>
|
||||
<%= link_to(item[:label], item[:url],
|
||||
class: "breadcrumbs-link",
|
||||
title: item[:label]) %>
|
||||
<span class="delimiter">
|
||||
<%= image_tag "icon_small/navigate_next.svg",
|
||||
alt: "navigate next",
|
||||
class: "navigate_next" %>
|
||||
</span>
|
||||
<% last_item = last_breadcrumb_items.last %>
|
||||
<span class="breadcrumbs-link" title="<%= last_item[:label] %>">
|
||||
<%= last_item[:label] %>
|
||||
</span>
|
||||
<% else %>
|
||||
<% last_item = @breadcrumbs_items.pop %>
|
||||
<% @breadcrumbs_items.each do |item| %>
|
||||
<%= link_to(item[:label], item[:url],
|
||||
class: "breadcrumbs-link",
|
||||
title: item[:label]) %>
|
||||
<span class="delimiter">
|
||||
<img src="<%= asset_path "icon_small/navigate_next.svg"%>"
|
||||
alt="navigate next"
|
||||
class="navigate_next">
|
||||
</span>
|
||||
|
||||
<% end %>
|
||||
<span class="breadcrumbs-link" title="<%= last_item[:label] %>">
|
||||
<%= last_item[:label] %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -3504,6 +3504,11 @@ en:
|
|||
url:
|
||||
not_valid: "Not valid URL"
|
||||
|
||||
breadcrumbs:
|
||||
projects: "Projects"
|
||||
inventories: "Inventories"
|
||||
protocols: "Protocol templates"
|
||||
labels: "Label templates"
|
||||
|
||||
Add: "Add"
|
||||
Asset: "File"
|
||||
|
|
Loading…
Reference in a new issue