mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-14 02:44:54 +08:00
Merge pull request #657 from mz3944/mz-SCI-1276
Repositories UI - show all/show assigned [SCI-1276]
This commit is contained in:
commit
30b204e0ed
4 changed files with 37 additions and 0 deletions
|
@ -34,9 +34,13 @@ var loadFirstTime = true;
|
|||
var table;
|
||||
var originalHeader;
|
||||
|
||||
// Tells whether to filter only assigned repository records
|
||||
var viewAssigned;
|
||||
|
||||
function dataTableInit() {
|
||||
// Make a copy of original repository table header
|
||||
originalHeader = $('#repository-table thead').children().clone();
|
||||
viewAssigned = 'assigned';
|
||||
table = $('#repository-table').DataTable({
|
||||
order: [[2, 'desc']],
|
||||
dom: "R<'row'<'col-sm-9-custom toolbar'l><'col-sm-3-custom'f>>tpi",
|
||||
|
@ -54,6 +58,9 @@ function dataTableInit() {
|
|||
destroy: true,
|
||||
ajax: {
|
||||
url: $('#repository-table').data('source'),
|
||||
data: function(d) {
|
||||
d.assigned = viewAssigned;
|
||||
},
|
||||
global: false,
|
||||
type: 'POST'
|
||||
},
|
||||
|
@ -361,6 +368,27 @@ function onClickAddRecord() {
|
|||
adjustTableHeader();
|
||||
}
|
||||
|
||||
(function onClickToggleAssignedRecords() {
|
||||
$('.repository-assign-group > .btn').click(function() {
|
||||
$('.btn-group > .btn').removeClass('active btn-primary');
|
||||
$('.btn-group > .btn').addClass('btn-default');
|
||||
$(this).addClass('active btn-primary');
|
||||
});
|
||||
|
||||
$('#assigned-repo-records').on('click', function() {
|
||||
viewAssigned = 'assigned';
|
||||
table.ajax.reload(function() {
|
||||
initRowSelection();
|
||||
}, false);
|
||||
});
|
||||
$('#all-repo-records').on('click', function() {
|
||||
viewAssigned = 'all';
|
||||
table.ajax.reload(function() {
|
||||
initRowSelection();
|
||||
}, false);
|
||||
});
|
||||
})();
|
||||
|
||||
function onClickAssignRecords() {
|
||||
animateSpinner();
|
||||
$.ajax({
|
||||
|
|
|
@ -21,6 +21,7 @@ class RepositoryDatatable < AjaxDatatablesRails::Base
|
|||
'regex' => false,
|
||||
'caseInsensitive' => true },
|
||||
'columns' => [],
|
||||
'assigned' => 'assigned',
|
||||
'ColReorder' => [*0..4]
|
||||
}
|
||||
5.times do
|
||||
|
@ -165,6 +166,7 @@ class RepositoryDatatable < AjaxDatatablesRails::Base
|
|||
# number of samples/all samples it's dependant upon sort_record query
|
||||
def fetch_records
|
||||
records = get_raw_records
|
||||
records = @assigned_rows if @my_module && params[:assigned] == 'assigned'
|
||||
records = sort_records(records) if params[:order].present?
|
||||
escape_special_chars
|
||||
records = filter_records(records) if params[:search].present? &&
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
|
||||
<h3><%= @repository.name %></h3>
|
||||
|
||||
<div id="show-assigned-buttons" class="btn-group repository-assign-group" data-toggle="buttons">
|
||||
<button type="button" class="active btn btn-primary" id="assigned-repo-records"><%= t("repositories.view_assigned_records") %></button>
|
||||
<button type="button" class="btn btn-default" id="all-repo-records"><%= t("repositories.view_all_records") %></button>
|
||||
</div>
|
||||
|
||||
<div class="toolbarButtons" style="display:none">
|
||||
<% if can_assign_repository_records(@my_module, @repository) %>
|
||||
<button type="button" class="btn btn-default"
|
||||
|
|
|
@ -888,6 +888,8 @@ en:
|
|||
column_create: "Create"
|
||||
columns_delete: "Delete"
|
||||
columns_visibility: "Visible columns"
|
||||
view_all_records: "View all records"
|
||||
view_assigned_records: "View assigned records"
|
||||
modal_delete_record:
|
||||
title: "Delete record"
|
||||
notice: "Are you sure you want to delete the selected records?"
|
||||
|
|
Loading…
Reference in a new issue