scinote-web/app/views/my_modules/protocols/_protocol_options_dropdown.html.erb
2020-05-14 16:41:02 +02:00

50 lines
2.4 KiB
Text

<% 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 sci-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"
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>