Refresh sidebar when project is archived/restored [SCI-2881]

This commit is contained in:
Oleksii Kriuchykhin 2018-11-29 14:20:20 +01:00
parent 60a19734b2
commit 2c96f08b98
4 changed files with 31 additions and 3 deletions

View file

@ -8,7 +8,7 @@
// - refactor view handling using library, ex. backbone.js
/* global Comments CounterBadge animateSpinner initFormSubmitLinks HelperModule
I18n */
I18n setupSidebarTree */
//= require comments
(function() {
@ -454,6 +454,16 @@
} else {
TABLE.draw();
}
// Also refresh sidebar tree navigation
$.ajax({
url: $('#projects-cards-view').data('projects-sidebar-url'),
type: 'GET',
dataType: 'json',
success: function(data) {
$('#slide-panel .tree').html('<ul>' + data.html + '</ul>');
setupSidebarTree();
}
});
}
function loadCardsView() {

View file

@ -9,7 +9,7 @@ class ProjectsController < ApplicationController
notifications reports
samples experiment_archive
delete_samples samples_index)
before_action :load_projects_tree, only: %i(show samples archive
before_action :load_projects_tree, only: %i(sidebar show samples archive
experiment_archive)
before_action :load_archive_vars, only: :archive
before_action :check_view_permissions, only: %i(show reports notifications
@ -67,6 +67,19 @@ class ProjectsController < ApplicationController
end
end
def sidebar
respond_to do |format|
format.json do
render json: {
html: render_to_string(
partial: 'shared/sidebar/projects.html.erb',
formats: :html
)
}
end
end
end
def archive
index
end

View file

@ -153,7 +153,11 @@
</div>
<div class="tab-content">
<div class="tab-pane active" id="projects-cards-view" data-projects-url="<%= projects_path %>"></div>
<div class="tab-pane active"
id="projects-cards-view"
data-projects-url="<%= projects_path %>"
data-projects-sidebar-url="<%= projects_sidebar_path %>">
</div>
<div class="tab-pane" id="projects-table-view">
<%= render partial: "projects/index/team_projects_table" %>
</div>

View file

@ -207,6 +207,7 @@ Rails.application.routes.draw do
get 'projects/archive', to: 'projects#archive', as: 'projects_archive'
post 'projects/index_dt', to: 'projects#index_dt', as: 'projects_index_dt'
get 'projects/sidebar', to: 'projects#sidebar', as: 'projects_sidebar'
get 'projects/dt_state_load', to: 'projects#dt_state_load',
as: 'projects_dt_state_load'