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