Add protocol options dropdown

This commit is contained in:
Mojca Lorber 2020-04-21 10:03:53 +02:00
parent be47efce74
commit 6fecee8c0c
7 changed files with 70 additions and 55 deletions

View file

@ -86,6 +86,16 @@
} }
} }
} }
.dropdown-menu {
a {
padding: 8px 20px;
}
.fas {
padding-right: 5px;
}
}
} }
} }
} }

View file

@ -921,13 +921,6 @@ ul.content-activities {
flex-wrap: wrap; flex-wrap: wrap;
margin-bottom: 5px; margin-bottom: 5px;
.protocol-button {
.sci-btn-group {
float: left;
}
}
.protocol-status-bar { .protocol-status-bar {
display: flex; display: flex;
height: 40px; height: 40px;

View file

@ -2,7 +2,6 @@
<div class="protocol-status-bar" data-role="protocol-status-bar"> <div class="protocol-status-bar" data-role="protocol-status-bar">
<%= render partial: "my_modules/protocols/protocol_status_bar.html.erb" %> <%= render partial: "my_modules/protocols/protocol_status_bar.html.erb" %>
</div> </div>
<%= render partial: "my_modules/protocols/protocol_buttons.html.erb" %>
<% if can_manage_protocol_in_module?(@protocol) %> <% if can_manage_protocol_in_module?(@protocol) %>
<%= render partial: "my_modules/recent_protocol_dropdown.html.erb", locals: {protocol: @my_module.protocol}%> <%= render partial: "my_modules/recent_protocol_dropdown.html.erb", locals: {protocol: @my_module.protocol}%>
<% end %> <% end %>

View file

@ -69,6 +69,9 @@
<h2><%= t('my_modules.protocol.title') %></h2> <h2><%= t('my_modules.protocol.title') %></h2>
</div> </div>
</a> </a>
<div class="actions-block">
<%= render partial: "my_modules/protocols/protocol_options_dropdown" %>
</div>
</div> </div>
<div class="collapse" id="protocol-container"> <div class="collapse" id="protocol-container">
<%= render partial: "my_module_protocol" %> <%= render partial: "my_module_protocol" %>

View file

@ -1,41 +0,0 @@
<div class="btn-group protocol-button" role="group" aria-label="">
<div class="sci-btn-group">
<a class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#">
<span class="fas fa-download"></span>
<span class="hidden-xs-custom">&nbsp;<%= t("my_modules.protocols.buttons.load_protocol") %></span>
</a>
<ul class="dropdown-menu">
<% if can_manage_protocol_in_module?(@protocol) %>
<li>
<%= link_to load_from_repository_modal_protocol_path(@protocol, format: :json), remote: true, data: { action: "load-from-repository" } do %>
<span class="fas fa-book"></span>&nbsp;<%= t("my_modules.protocols.buttons.load_protocol_from_repository") %>
<% end %>
</li>
<% else %>
<li class="disabled"><a href="#"><span class="fas fa-book"></span>&nbsp;<%= t("my_modules.protocols.buttons.load_protocol_from_repository") %></a></li>
<% end %>
<% if can_manage_protocol_in_module?(@protocol) %>
<li>
<a class="btn-open-file" href="#" data-action="load-from-file" data-import-url="<%= load_from_file_protocol_path(@protocol, format: :json) %>">
<span class="fas fa-paperclip"></span>&nbsp;<%= t("my_modules.protocols.buttons.load_protocol_from_file") %>
<input type="file" value="" accept=".eln" data-turbolinks="false">
</a>
</li>
<% else %>
<li class="disabled"><a href="#"><span class="fas fa-paperclip"></span>&nbsp;<%= t("my_modules.protocols.buttons.load_protocol_from_file") %></a></li>
<% end %>
</ul>
<% if can_read_experiment?(@my_module.experiment) %>
<%= link_to raw("<span class=\"fas fa-upload\"></span><span class=\"hidden-xs-custom\">&nbsp;" + t('my_modules.protocols.buttons.export') + "</span>"), export_protocols_path(protocol_ids: @protocol.id, my_module_id: @my_module.id), class: "btn btn-secondary", data: { turbolinks: false } %>
<% else %>
<a href="#" class="btn btn-secondary disabled"><span class="fas fa-upload"></span><span class="hidden-xs-custom">&nbsp;<%= t("my_modules.protocols.buttons.export") %></span></a>
<% end %>
<% if can_read_protocol_in_module?(@protocol) && can_create_protocols_in_repository?(@protocol.team) %>
<a id="protocol-copy-to-repository" class="btn btn-secondary" data-action="copy-to-repository" data-hook="protocol-copy-to-repository" data-remote="true" href="<%= copy_to_repository_modal_protocol_path(@protocol, format: :json) %>">
<span class="fas fa-copy"></span><span class="hidden-xs-custom">&nbsp;<%= t("my_modules.protocols.buttons.copy_to_repository") %></span>
</a>
<% else %>
<a href="#" class="btn btn-secondary disabled"><span class="fas fa-copy"></span><span class="hidden-xs-custom">&nbsp;<%= t("my_modules.protocols.buttons.copy_to_repository") %></span></a>
<% end %>
</div>
</div>

View file

@ -0,0 +1,51 @@
<% protocol_readable = can_read_protocol_in_module?(@protocol) %>
<% protocol_editable = can_manage_protocol_in_module?(@protocol) %>
<% protocol_savable_to_repo = can_read_protocol_in_module?(@protocol) && can_create_protocols_in_repository?(@protocol.team) %>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownProtocolOptions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="fas fa-wrench"></span>
<span><%= t('my_modules.protocol.options_dropdown.title') %></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownProtocolOptions">
<li>
<a data-action="load-from-repository"
class="<%= 'disabled' unless protocol_editable %>"
data-remote="true"
href="<%= protocol_editable ? load_from_repository_modal_protocol_path(@protocol, format: :json) : '#' %>">
<span class="fas fa-edit"></span>
<span><%= t('my_modules.protocol.options_dropdown.load_from_repo') %></span>
</a>
</li>
<li>
<a data-action="load-from-file"
class="btn-open-file <%= 'disabled' unless protocol_editable %>"
href="#"
data-import-url="<%= protocol_editable ? load_from_file_protocol_path(@protocol, format: :json) : '#' %>">
<span class="fas fa-download"></span>
<span><%= t('my_modules.protocol.options_dropdown.import') %></span>
<input type="file" value="" accept=".eln" data-turbolinks="false">
</a>
</li>
<li>
<a class="<%= 'disabled' unless protocol_readable %>"
data-turbolinks="false"
href="<%= protocol_readable ? export_protocols_path(protocol_ids: @protocol.id, my_module_id: @my_module.id) : '#' %>">
<span class="fas fa-upload"></span>
<span><%= t('my_modules.protocol.options_dropdown.export') %></span>
</a>
</li>
<li>
<a id="protocol-copy-to-repository"
data-action="copy-to-repository"
data-hook="protocol-copy-to-repository"
class="<%= 'disabled' unless protocol_savable_to_repo %>"
data-remote="true"
href="<%= protocol_savable_to_repo ? copy_to_repository_modal_protocol_path(@protocol, format: :json) : '#' %>">
<span class="fas fa-save"></span>
<span><%= t('my_modules.protocol.options_dropdown.save_to_repo') %></span>
</a>
</li>
</ul>
</div>

View file

@ -607,6 +607,12 @@ en:
assign_from: "Assign from" assign_from: "Assign from"
protocol: protocol:
title: "Protocol" title: "Protocol"
options_dropdown:
title: "Protocol options"
load_from_repo: "Load from repository"
import: "Import protocol"
export: "Export protocol"
save_to_repo: "Save to repository"
buttons: buttons:
complete: "Complete Task" complete: "Complete Task"
uncomplete: "Uncomplete Task" uncomplete: "Uncomplete Task"
@ -687,12 +693,6 @@ en:
btns_parent_and_self_newer: btns_parent_and_self_newer:
title: "Newer version in repository and task" title: "Newer version in repository and task"
text: "There is a newer <a href='#' data-toggle='tooltip' data-placement='below' title='Last modified at %{parent_ts}'>version</a> of this protocol in the repository. This <a href='#' data-toggle='tooltip' data-placement='below' title='Last modified at %{self_ts}'>version</a> of protocol is newer than the version stored in protocol repository." text: "There is a newer <a href='#' data-toggle='tooltip' data-placement='below' title='Last modified at %{parent_ts}'>version</a> of this protocol in the repository. This <a href='#' data-toggle='tooltip' data-placement='below' title='Last modified at %{self_ts}'>version</a> of protocol is newer than the version stored in protocol repository."
buttons:
load_protocol: "Load Protocol"
load_protocol_from_repository: "from repository"
load_protocol_from_file: "from computer"
export: "Export Protocol"
copy_to_repository: "Copy To Protocol Repository"
confirm_link_update_modal: confirm_link_update_modal:
unlink_title: "Unlink protocol" unlink_title: "Unlink protocol"
unlink_message: "Are you sure you want to unlink the task protocol from the repository version? This will stop any tracking of changes." unlink_message: "Are you sure you want to unlink the task protocol from the repository version? This will stop any tracking of changes."