Merge pull request #2706 from aignatov-bio/ai-sci-4820-fix-sidebar-inventory-refresh

Improve active/archive switcher [SCI-4820]
This commit is contained in:
aignatov-bio 2020-07-08 09:29:16 +02:00 committed by GitHub
commit 716319354b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -100,9 +100,9 @@
function reloadSidebar() {
var slidePanel = $('#slide-panel');
var archived;
if ($('.repositories-index').hasClass('archived')) archived = true;
$.get(slidePanel.data('sidebar-url'), { archived: archived }, function(data) {
$.get(slidePanel.data('sidebar-url'), {
archived: $('.repositories-index').hasClass('archived')
}, function(data) {
slidePanel.html(data.html);
$('.create-new-repository').initializeModal('#create-repo-modal');
});
@ -111,12 +111,12 @@
function initRepositoryViewSwitcher() {
var viewSwitch = $('.view-switch');
viewSwitch.on('click', '.view-switch-archived', function() {
$('.repositories-index').toggleClass('archived active');
$('.repositories-index').removeClass('active').addClass('archived');
initRepositoriesDataTable('#repositoriesList', true);
reloadSidebar();
});
viewSwitch.on('click', '.view-switch-active', function() {
$('.repositories-index').toggleClass('archived active');
$('.repositories-index').removeClass('archived').addClass('active');
initRepositoriesDataTable('#repositoriesList');
reloadSidebar();
});

View file

@ -37,7 +37,7 @@ class RepositoriesController < ApplicationController
render json: {
html: render_to_string(partial: 'repositories/sidebar_list.html.erb', locals: {
repositories: @repositories,
archived: params[:archived]
archived: params[:archived] == 'true'
})
}
end
@ -376,7 +376,7 @@ class RepositoriesController < ApplicationController
def load_repositories
@repositories = Repository.accessible_by_teams(current_team).order('repositories.created_at ASC')
@repositories = if params[:archived] || @repository&.archived?
@repositories = if params[:archived] == 'true' || @repository&.archived?
@repositories.archived
else
@repositories.active