Merge pull request #2700 from aignatov-bio/ai-sci-4801-inventory-list-sorting-date-issue

Fix date columns sorting in repositories list [SCI-4801]
This commit is contained in:
aignatov-bio 2020-07-08 09:30:10 +02:00 committed by GitHub
commit a994c75885
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 31 deletions

View file

@ -31,8 +31,8 @@
}
function initRepositoriesDataTable(tableContainer, archived = false) {
var tableTemplate = archived ? $('#archivedRepositoriesListTable').html() : $('#activeRepositoriesListTable').html();
$.get($(tableTemplate).data('source'), function(data) {
var tableTemplate = $('#RepositoriesListTable').html();
$.get($(tableTemplate).data('source'), {archived: archived}, function(data) {
if (REPOSITORIES_TABLE) REPOSITORIES_TABLE.destroy();
CHECKBOX_SELECTOR = null;
$('.content-body').html(tableTemplate);
@ -65,6 +65,22 @@
render: function(value, type, row) {
return `<a href="${row.repositoryUrl}">${value}</a>`;
}
}, {
targets: 5,
render: {
_: 'display',
sort: 'sort'
}
}, {
targets: 7,
visible: archived,
render: {
_: 'display',
sort: 'sort'
}
}, {
targets: 8,
visible: archived
}],
fnInitComplete: function(e) {
var dataTableWrapper = $(e.nTableWrapper);

View file

@ -13,9 +13,15 @@ module RepositoriesDatatableHelper
'2': repository.repository_rows.size,
'3': shared_label(repository, team),
'4': escape_input(repository.team.name),
'5': I18n.l(repository.created_at, format: :full),
'5': {
display: I18n.l(repository.created_at, format: :full),
sort: repository.created_at.to_i
},
'6': escape_input(repository.created_by.full_name),
'7': (I18n.l(repository.archived_on, format: :full) if repository.archived_on),
'7': {
display: (I18n.l(repository.archived_on, format: :full) if repository.archived_on),
sort: repository.archived_on&.to_i
},
'8': escape_input(repository.archived_by&.full_name),
'repositoryUrl': repository_path(repository),
'DT_RowAttr': {

View file

@ -24,35 +24,10 @@
</div>
<% end %>
<!-- Active table template -->
<template id="activeRepositoriesListTable">
<!-- table template -->
<template id="RepositoriesListTable">
<table id="repositoriesList" class="table"
data-source="<%= team_repositories_path(current_team, format: :json) %>">
<thead>
<tr>
<th>
<div class="sci-checkbox-container">
<input value="1" type="checkbox" class="sci-checkbox select-all-checkbox">
<span class="sci-checkbox-label"></span>
</div>
</th>
<th><%= t('libraries.index.table.name') %></th>
<th><%= t('libraries.index.table.number_of_items') %></th>
<th><%= t('libraries.index.table.shared') %></th>
<th><%= t('libraries.index.table.ownership') %></th>
<th><%= t('libraries.index.table.added_on') %></th>
<th><%= t('libraries.index.table.added_by') %></th>
</tr>
</thead>
</table>
</template>
<!-- Archived table template -->
<template id="archivedRepositoriesListTable">
<table id="repositoriesList" class="table"
data-source="<%= team_repositories_path(current_team, archived: true, format: :json) %>"
>
<thead>
<tr>
<th>