scinote-web/app/views/experiments/_show_header.html.erb
2023-04-26 10:34:02 +02:00

126 lines
6.6 KiB
Text

<div class="content-header sticky-header">
<div class="title-row">
<i class="fas fa-bars sci--layout--navigator-open p-2 cursor-pointer"></i>
<h1 class="experimnet-name" data-toggle="tooltip" data-placement="bottom" title="<%= @experiment.name %>">
<% if @experiment.archived? %>
<i class="fas fa-archive" data-view-mode="archived"></i>
<% end %>
<% if @inline_editable_title_config.present? %>
<%= render partial: "shared/inline_editing",
locals: {
initial_value: @experiment.name,
config: @inline_editable_title_config
} %>
<% else %>
<div class="name-readonly-placeholder">
<%= @experiment.name %>
</div>
<% end %>
</h1>
<div class="header-actions experiment-header">
<% if can_manage_experiment?(@experiment) || can_clone_experiment?(@experiment) %>
<!-- experiment actions -->
<span class="dropdown actions-button">
<button class="btn btn-light dropdown-toggle" type="button" id="exActionsMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="hidden-xs"><%= t('experiments.canvas.actions') %></span>
<span class="visible-xs-inline"><i class="fas fa-sort"></i></span>
<span class="caret"></span>
</button>
<%= render partial: 'experiments/dropdown_actions.html.erb',
locals: { project: @project, experiment: @experiment, action_name: action_name } %>
</span>
<% end %>
<%= render layout: 'shared/view_switch', locals: { disabled: false, name: t("toolbar.#{action_name == 'module_archive' ? 'cards' : action_name }_view") } do %>
<% if params[:view_mode] == 'archived' || params[:action] == "module_archive" %>
<li class="form-dropdown-item">
<%= button_to(view_type_experiment_path(@experiment, view_mode: 'archived'),
method: :put,
remote: true,
class: "btn button-to #{ action_name == 'table' ? 'btn-primary' : 'btn-light' }",
form_class: 'change-my-modules-view-type-form',
params: { experiment: { view_type: 'table', id: @experiment.id } }) do %>
<span class="<%= 'text-light' if action_name == 'table' %>">
<%= t('toolbar.table_view') %>
</span>
<% end %>
</li>
<li class="form-dropdown-item">
<%= button_to(view_type_experiment_path(@experiment, view_mode: 'archived'),
method: :put,
remote: true,
class: "btn button-to #{ action_name == 'module_archive' ? 'btn-primary' : 'btn-light'}",
form_class: 'change-my-modules-view-type-form',
params: { experiment: { view_type: 'canvas', id: @experiment.id } }) do %>
<span class="<%= 'text-light' if action_name == 'module_archive' %>">
<%= t('toolbar.cards_view') %>
</span>
<% end %>
</li>
<% else %>
<li class="form-dropdown-item">
<%= button_to(view_type_experiment_path(@experiment),
method: :put,
remote: true,
class: "btn button-to #{ action_name == 'table' ? 'btn-primary text-light' : 'btn-light' }",
form_class: 'change-my-modules-view-type-form',
params: { experiment: { view_type: 'table', id: @experiment.id } }) do %>
<span class="<%= 'text-light' if action_name == 'table' %>">
<%= t('toolbar.table_view') %>
</span>
<% end %>
</li>
<li class="form-dropdown-item">
<%= button_to(view_type_experiment_path(@experiment),
method: :put,
remote: true,
class: "btn button-to #{ action_name == 'canvas' ? 'btn-primary text-light' : 'btn-light'}",
form_class: 'change-my-modules-view-type-form',
params: { experiment: { view_type: 'canvas', id: @experiment.id } }) do %>
<span class="<%= 'text-light' if action_name == 'canvas' %>">
<%= t('toolbar.canvas_view') %>
</span>
<% end %>
</li>
<% end %>
<% end %>
<%= render layout: 'shared/state_view_switch', locals: { disabled: false } do %>
<% unless @experiment.archived_branch? %>
<li>
<%= link_to my_modules_experiment_path(@experiment), class: "#{'form-dropdown-state-item' unless (action_name == 'module_archive' || params[:view_mode] == 'archived')}" do %>
<%= t('toolbar.active_state') %>
<% end %>
</li>
<li>
<%= link_to my_modules_experiment_path(@experiment, view_mode: :archived), class: "#{'form-dropdown-state-item' if (action_name == 'module_archive' || params[:view_mode] == 'archived')}" do %>
<%= t('toolbar.archived_state') %>
<% end %>
</li>
<% end %>
<% end %>
<% if action_name == 'table' %>
<%= render partial: 'table_filters.html.erb' %>
<div class="dropdown sort-menu">
<button class="btn btn-light icon-btn dropdown-toggle" type="button" id="sortMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fas fa-sort-amount-up"></i>
</button>
<ul id="sortMenuDropdown" class="dropdown-menu sort-task-menu <%= params[:view_mode] %> dropdown-menu-right" aria-labelledby="sortMenu">
<% %w(atoz ztoa due_first due_last archived_old archived_new).each_with_index do |sort, i| %>
<% if i.even? && i.positive? %>
<li class="divider" <%= i > 3 ? 'data-view-mode=archived' : '' %>></li>
<% end %>
<li <%= %w(archived_new archived_old).include?(sort) ? 'data-view-mode=archived' : '' %>>
<a class="<%= 'selected' if @current_sort == sort %>"
data-sort="<%= sort %>" >
<%= t("general.sort.#{sort}_html") %>
</a>
</li>
<% end %>
</ul>
</div>
<% end %>
</div>
</div>
</div>