mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
Refactor sidebar
This commit is contained in:
parent
34af50a9d0
commit
ed2226c14b
4 changed files with 87 additions and 86 deletions
|
@ -23,7 +23,7 @@
|
|||
<span title="<%= @project.name %>"><%= @project.name %></span>
|
||||
<% end %>
|
||||
</span>
|
||||
<%= render 'shared/sidebar_elements' %>
|
||||
<%= render partial: 'shared/sidebar/experiments', locals: { project: @project } %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
<ul>
|
||||
<% if @project.active_experiments.present? then %>
|
||||
<% @project.active_experiments.each do |experiment| %>
|
||||
<li class="<%= "active" if experiment_page? %>">
|
||||
<span class="tree-link line-wrap">
|
||||
<i></i>
|
||||
<% if !experiment_page? %>
|
||||
<%= link_to experiment.name, experiment_action_to_link_to(experiment), title: experiment.name %>
|
||||
<% else %>
|
||||
<span title="<%= experiment.name %>"><%= experiment.name %></span>
|
||||
<% end %>
|
||||
</span>
|
||||
<% if experiment.active_modules.present? then %>
|
||||
<ul>
|
||||
<% experiment.active_module_groups.each do |my_module_group| %>
|
||||
<li data-module-group="<%= my_module_group.id %>">
|
||||
<span>
|
||||
<i></i>
|
||||
<span class="line-wrap short" title="<%= my_module_group.name %>">
|
||||
<%= my_module_group.name %>
|
||||
</span>
|
||||
<% if is_canvas? %>
|
||||
<a href="" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
|
||||
<% end %>
|
||||
</span>
|
||||
<% if my_module_group.my_modules.present? then %>
|
||||
<ul>
|
||||
<% my_module_group.my_modules.sort_by{|m| m.workflow_order}.each do |my_module| %>
|
||||
<li class="leaf <%= "active" if currently_active? my_module %>" data-module-id="<%= my_module.id %>">
|
||||
<span class="tree-link">
|
||||
<% if currently_active? my_module %>
|
||||
<%= my_module.name %>
|
||||
<% else %>
|
||||
<% if can_view_module(my_module) then %>
|
||||
<%= link_to my_module.name, module_action_to_link_to(my_module), class: "module-link" %>
|
||||
<% else %>
|
||||
<%= my_module.name %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if is_canvas? %>
|
||||
<a href="#" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
|
||||
<% end %>
|
||||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% modules_without_group = experiment.modules_without_group %>
|
||||
<% if modules_without_group.present? then %>
|
||||
<li>
|
||||
<span>
|
||||
<i></i>
|
||||
<span class='sidebar-no-module-group'><%= t("sidebar.no_module_group") %></span>
|
||||
</span>
|
||||
<ul>
|
||||
<% modules_without_group.each do |my_module| %>
|
||||
<li class="leaf <%= "active" if currently_active? my_module %>" data-module-id="<%= my_module.id %>">
|
||||
<span class="tree-link">
|
||||
<% if currently_active? my_module %>
|
||||
<%= my_module.name %>
|
||||
<% else %>
|
||||
<%= link_to my_module.name, module_action_to_link_to(my_module) %>
|
||||
<% end %>
|
||||
<% if is_canvas? %>
|
||||
<a href="" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
|
||||
<% end %>
|
||||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<li>
|
||||
<%= link_to new_project_experiment_path(@project), id: 'new-experiment', remote: true do %>
|
||||
<span class="glyphicon glyphicon-plus"></span> <i><%= t('experiments.new.create') %></i>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
22
app/views/shared/sidebar/_experiments.html.erb
Normal file
22
app/views/shared/sidebar/_experiments.html.erb
Normal file
|
@ -0,0 +1,22 @@
|
|||
<ul>
|
||||
<% if project.active_experiments.present? then %>
|
||||
<% project.active_experiments.each do |experiment| %>
|
||||
<li class="<%= "active" if experiment_page? %>">
|
||||
<span class="tree-link line-wrap">
|
||||
<i></i>
|
||||
<% if !experiment_page? %>
|
||||
<%= link_to experiment.name, experiment_action_to_link_to(experiment), title: experiment.name %>
|
||||
<% else %>
|
||||
<span title="<%= experiment.name %>"><%= experiment.name %></span>
|
||||
<% end %>
|
||||
</span>
|
||||
<%= render partial: 'shared/sidebar/my_modules', locals: { experiment: experiment } %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<li>
|
||||
<%= link_to new_project_experiment_path(project), id: 'new-experiment', remote: true do %>
|
||||
<span class="glyphicon glyphicon-plus"></span> <i><%= t('experiments.new.create') %></i>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
64
app/views/shared/sidebar/_my_modules.html.erb
Normal file
64
app/views/shared/sidebar/_my_modules.html.erb
Normal file
|
@ -0,0 +1,64 @@
|
|||
<% if experiment.active_modules.present? then %>
|
||||
<ul>
|
||||
<% experiment.active_module_groups.each do |my_module_group| %>
|
||||
<li data-module-group="<%= my_module_group.id %>">
|
||||
<span>
|
||||
<i></i>
|
||||
<span class="line-wrap short" title="<%= my_module_group.name %>">
|
||||
<%= my_module_group.name %>
|
||||
</span>
|
||||
<% if is_canvas? %>
|
||||
<a href="" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
|
||||
<% end %>
|
||||
</span>
|
||||
<% if my_module_group.my_modules.present? then %>
|
||||
<ul>
|
||||
<% my_module_group.my_modules.sort_by{|m| m.workflow_order}.each do |my_module| %>
|
||||
<li class="leaf <%= "active" if currently_active? my_module %>" data-module-id="<%= my_module.id %>">
|
||||
<span class="tree-link">
|
||||
<% if currently_active? my_module %>
|
||||
<%= my_module.name %>
|
||||
<% else %>
|
||||
<% if can_view_module(my_module) then %>
|
||||
<%= link_to my_module.name, module_action_to_link_to(my_module), class: "module-link" %>
|
||||
<% else %>
|
||||
<%= my_module.name %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if is_canvas? %>
|
||||
<a href="#" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
|
||||
<% end %>
|
||||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% modules_without_group = experiment.modules_without_group %>
|
||||
<% if modules_without_group.present? then %>
|
||||
<li>
|
||||
<span>
|
||||
<i></i>
|
||||
<span class='sidebar-no-module-group'><%= t("sidebar.no_module_group") %></span>
|
||||
</span>
|
||||
<ul>
|
||||
<% modules_without_group.each do |my_module| %>
|
||||
<li class="leaf <%= "active" if currently_active? my_module %>" data-module-id="<%= my_module.id %>">
|
||||
<span class="tree-link">
|
||||
<% if currently_active? my_module %>
|
||||
<%= my_module.name %>
|
||||
<% else %>
|
||||
<%= link_to my_module.name, module_action_to_link_to(my_module) %>
|
||||
<% end %>
|
||||
<% if is_canvas? %>
|
||||
<a href="" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
|
||||
<% end %>
|
||||
</span>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
Loading…
Reference in a new issue