scinote-web/app/views/shared/_samples.html.erb

168 lines
7.3 KiB
Text

<%= render partial: "samples/import_samples_modal" %>
<%= render partial: "samples/delete_samples_modal" %>
<%= render partial: "samples/delete_custom_field_modal" %>
<%= render partial: 'samples/export_samples_modal' %>
<!-- Modal for parsing sample sheets should be empty at first -->
<div class="modal fade" id="modal-parse-samples" tabindex="-1" role="dialog" aria-labelledby=="modal-parse-samples-label"></div>
<div id="alert-container"></div>
<% if can_read_team?(@team) %>
<%= bootstrap_form_tag(url: export_samples_team_path(@team),
html: { id: 'form-export', class: 'hidden' }) do |f| %>
<% end %>
<% end %>
<%= form_for :sample, url: form_submit_link, html: {id: "form-samples"} do |f|%>
<div id="samples-toolbar"
<% if @my_module %>
data-module-id="<%= @my_module.id %>"
<% end %>>
<% if can_manage_samples?(@team) %>
<button type="button" class="btn btn-default editAdd" id="addSample" onclick="onClickAddSample()">
<span class="glyphicon glyphicon-plus"></span>
<span class="hidden-xs"><%= t("samples.add_new_sample") %></span>
</button>
<button type="button" class="btn btn-default" id="importSamplesButton" data-toggle="modal" data-target="#modal-import-samples">
<span class="glyphicon glyphicon-cloud-upload"></span>
<span class="hidden-xs"><%= t("samples.import") %></span>
</button>
<% end %>
<% if can_read_team?(@team) %>
<a href="#" class="btn btn-default" id="exportSamplesButton">
<span class="glyphicon glyphicon-cloud-download"></span>
<span class="hidden-xs"><%= t("samples.export") %></span>
</a>
<div id="show-assigned-buttons" class="btn-group sample-assign-group" data-toggle="buttons">
<button type="button" class="active btn btn-primary" id="assignedSamples"><%= t("samples.view_assigned_samples") %></button>
<button type="button" class="btn btn-default" id="allSamples"><%= t("samples.view_all_samples") %></button>
</div>
<% end %>
<div id="datatables-buttons" style="display: inline;">
<div id="samples-columns-dropdown" class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">
<%= t('samples.columns') %>
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right smart-dropdown" id="samples-columns-list">
<% if can_manage_sample_elements?(@team) %>
<li class="add-new-column-form">
<div id="new-column-form" class="form-group" data-action="<%= team_custom_fields_path(@team) %>">
<div class="input-group">
<input class="form-control" id="new-column-name" placeholder="<%= t("samples.column_new_text") %>">
<span class="input-group-btn">
<a id="add-new-column-button" class="btn btn-primary">
<%= t("samples.column_create") %>
</a>
</span>
</div>
</div>
</li>
<% end %>
</ul>
</div>
</div>
<% if can_add_sample_related_things_to_team %>
<div class="dropdown pull-right" style="display: inline;">
<%= link_to(t('samples.types_and_groups'),
team_sample_types_path(@team,
project_id: (@project.id if @project),
my_module_id: (@my_module.id if @my_module),
experiment_id: (@experiment.id if @experiment)),
class: 'btn btn-default' ) %>
</div>
<% end %>
</div>
<div class="btn-group" id="saveCancel" data-toggle="buttons" style="display:none">
<button type="button" class="btn btn-primary" id="saveSample" onclick="onClickSave()">
<span class="glyphicon glyphicon-save"></span>
<%= t("samples.save_sample") %>
</button>
<button type="button" class="btn btn-default" id="cancelSave" onclick="onClickCancel()">
<span class="glyphicon glyphicon-remove visible-xs-inline"></span>
<span class="hidden-xs"><%= t("samples.cancel_save") %></span>
</button>
</div>
<!-- These buttons are appended to table in javascript, after table initialization. -->
<div class="toolbarButtons" style="display:none">
<button type="button" class="btn btn-default editAdd" id="editSample" onclick="onClickEdit()" disabled>
<span class="glyphicon glyphicon-pencil"></span>
<span class="hidden-xs-custom"><%= t("samples.edit_sample") %></span>
</button>
<% if can_manage_samples?(@team) %>
<button type="button" class="btn btn-default"
id="deleteSamplesButton" data-target="#deleteSamples" data-toggle="modal" disabled>
<span class="glyphicon glyphicon-trash"></span>
<span class="hidden-xs-custom"><%= t'samples.delete_samples' %></span>
<%= submit_tag I18n.t('samples.delete_samples'), :class => "hidden
delete_samples_submit" %>
</button>
<% end %>
<% if can_add_samples %>
<button type="button" class="btn btn-default"
id="assignSamples" onclick="$(this).next().click();" disabled>
<span class="glyphicon glyphicon-ok-circle"></span>
<span class="hidden-xs-custom"><%= t'samples.assign_samples_to_module' %></span>
</button>
<%= submit_tag MyModulesController::ASSIGN_SAMPLES, :class => "hidden" %>
<% end %>
<% if can_remove_samples %>
<button type="button" class="btn btn-default"
id="unassignSamples" onclick="$(this).next().click();" disabled>
<span class="glyphicon glyphicon-ban-circle"></span>
<span class="hidden-xs-custom"><%= t'samples.unassign_samples_to_module' %></span>
</button>
<%= submit_tag MyModulesController::UNASSIGN_SAMPLES, :class => "hidden" %>
<% end %>
</div>
<div class="samples-table">
<table id="samples" class="table"
data-current-uri="<%= request.original_url %>"
data-team-id="<%= @project.team.id %>"
data-user-id="<%= @current_user.id %>"
data-source="<%= @samples_index_link %>"
data-num-columns="<%= num_of_columns %>"
data-new-sample="<%= new_team_sample_path(team_id: @team) %>"
data-create-sample="<%= team_samples_path(team_id: @team) %>">
<thead>
<tr>
<th id="checkbox"><input name="select_all" value="1" type="checkbox"></th>
<th id="assigned"><%= t("samples.table.assigned") %></th>
<th id="sample-name"><%= t("samples.table.sample_name") %></th>
<th id="sample-type"><%= t("samples.table.sample_type") %></th>
<th id="sample-group"><%= t("samples.table.sample_group") %></th>
<th id="added-on"><%= t("samples.table.added_on") %></th>
<th id="added-by"><%= t("samples.table.added_by") %></th>
<% all_custom_fields.each do |cf| %>
<th class="custom-field"
id="<%= cf.id %>"
<%= 'data-editable' if can_update_or_delete_custom_field?(cf) %>
<%= 'data-deletable' if can_update_or_delete_custom_field?(cf) %>
<%= "data-edit-url='#{edit_team_custom_field_path(@team, cf)}'" %>
<%= "data-update-url='#{team_custom_field_path(@team, cf)}'" %>
<%= "data-destroy-html-url='#{team_custom_field_destroy_html_path(@team, cf)}'" %>
>
<%= display_tooltip(cf.name) %>
</th>
<% end %>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<% end %>
<%= stylesheet_link_tag 'datatables' %>
<%= javascript_include_tag("samples/samples") %>
<%= javascript_include_tag("samples/sample_datatable") %>