Merge pull request #2682 from aignatov-bio/ai-sci-4743-update-my-module-repoistories-dropdown-list

Update my module repositories dropdown list [SCI-4743]
This commit is contained in:
aignatov-bio 2020-06-24 11:54:07 +02:00 committed by GitHub
commit 3f309832fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View file

@ -96,6 +96,7 @@
if ($('.repositories-index').hasClass('archived')) archived = true;
$.get(slidePanel.data('sidebar-url'), { archived: archived }, function(data) {
slidePanel.html(data.html);
$('.create-new-repository').initializeModal('#create-repo-modal');
});
}
@ -147,6 +148,7 @@
});
});
$('.create-new-repository').initializeModal('#create-repo-modal');
initRepositoriesDataTable('#repositoriesList', $('.repositories-index').hasClass('archived'));
initRepositoryViewSwitcher();
}());

View file

@ -102,7 +102,16 @@ class MyModuleRepositoriesController < ApplicationController
end
def repositories_dropdown_list
@repositories = Repository.accessible_by_teams(current_team).order(:name)
@repositories = Repository.accessible_by_teams(current_team).joins("
LEFT OUTER JOIN repository_rows ON
repository_rows.repository_id = repositories.id
LEFT OUTER JOIN my_module_repository_rows ON
my_module_repository_rows.repository_row_id = repository_rows.id
AND my_module_repository_rows.my_module_id = #{@my_module.id}
").select('COUNT(my_module_repository_rows.id) as rows_count', :name, :id, :team_id)
.group(:id)
.having('COUNT(my_module_repository_rows.id) > 0 OR repositories.archived = FALSE')
.order(:name)
render json: { html: render_to_string(partial: 'my_modules/repositories/repositories_dropdown_list') }
end

View file

@ -1,20 +1,19 @@
<% @repositories.each do |repository| %>
<% assigned_items_count = @my_module.repository_rows_count(repository) %>
<li class="repository"
data-table-url="<%= full_view_table_my_module_repository_path(@my_module, repository) %>"
data-assign-url-modal="<%= assign_modal_my_module_repository_path(@my_module, repository) %>"
data-update-url-modal="<%= update_modal_my_module_repository_path(@my_module, repository)%>" data-repository-id="<%= repository.id %>"
data-rows-count="<%= assigned_items_count %>" >
data-rows-count="<%= repository.rows_count %>" >
<% if repository.shared_with?(current_team) %>
<span class="shared-icon">
<i class="fas fa-users"></i>
</span>
<% end %>
<span class="name" data-rows-count="<%= assigned_items_count %>"><%= repository.name %></span>
<% if assigned_items_count.positive? %>
<span class="name" data-rows-count="<%= repository.rows_count %>"><%= repository.name %></span>
<% if repository.rows_count.positive? %>
<span class="assigned-items">
<i class="fas fa-file-signature"></i>
<%= assigned_items_count %>
<%= repository.rows_count %>
</span>
<% end %>
</li>