mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 10:06:53 +08:00
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:
commit
3f309832fc
3 changed files with 16 additions and 6 deletions
|
@ -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();
|
||||
}());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue