diff --git a/app/assets/javascripts/repositories/index.js b/app/assets/javascripts/repositories/index.js index 00480663e..262948fe8 100644 --- a/app/assets/javascripts/repositories/index.js +++ b/app/assets/javascripts/repositories/index.js @@ -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(); }()); diff --git a/app/controllers/my_module_repositories_controller.rb b/app/controllers/my_module_repositories_controller.rb index b41711d39..3c0524fce 100644 --- a/app/controllers/my_module_repositories_controller.rb +++ b/app/controllers/my_module_repositories_controller.rb @@ -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 diff --git a/app/views/my_modules/repositories/_repositories_dropdown_list.html.erb b/app/views/my_modules/repositories/_repositories_dropdown_list.html.erb index 456ecb05a..1f022dffc 100644 --- a/app/views/my_modules/repositories/_repositories_dropdown_list.html.erb +++ b/app/views/my_modules/repositories/_repositories_dropdown_list.html.erb @@ -1,20 +1,19 @@ <% @repositories.each do |repository| %> - <% assigned_items_count = @my_module.repository_rows_count(repository) %>