From 9678372dd539d259afdf31f9cd8802bdd76a311e Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Thu, 2 Apr 2020 12:05:07 +0200 Subject: [PATCH] Add assigned repositories list --- .../stylesheets/my_modules/repositories.scss | 64 +++++++++++++++++++ app/controllers/my_modules_controller.rb | 1 + app/models/my_module.rb | 9 +++ .../inventories/_inventories_list.html.erb | 24 +++++++ app/views/my_modules/protocols.html.erb | 2 +- 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 app/views/my_modules/inventories/_inventories_list.html.erb diff --git a/app/assets/stylesheets/my_modules/repositories.scss b/app/assets/stylesheets/my_modules/repositories.scss index 34443255a..95557fd1b 100644 --- a/app/assets/stylesheets/my_modules/repositories.scss +++ b/app/assets/stylesheets/my_modules/repositories.scss @@ -74,3 +74,67 @@ } } } + +.my-module-assigned-repositories { + .assigned-repository { + border: $border-default; + border-radius: $border-radius-modal; + margin-bottom: 10px; + + .assigned-repository-caret { + align-items: center; + color: inherit; + display: flex; + height: 52px; + padding: 0 18px; + text-decoration: none; + + &:hover, + &:active { + text-decoration: none; + } + + &:not(.collapsed) .fa-caret-right { + @include rotate(90deg); + } + + .fa-caret-right { + flex-shrink: 0; + margin-right: 10px; + } + + .assigned-repository-title { + @include font-h3; + overflow: hidden; + padding-right: 55px; + position: relative; + text-overflow: ellipsis; + white-space: nowrap; + + &::after { + color: $color-alto; + content: attr(data-rows-count); + display: inline-block; + line-height: 22px; + padding-left: 5px; + position: absolute; + right: 0; + width: 55px; + } + } + + .action-buttons { + flex-grow: 1; + flex-shrink: 0; + text-align: right; + + .fas { + cursor: pointer; + line-height: 36px; + text-align: center; + width: 36px; + } + } + } + } +} diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index 70adfbabe..0291c0268 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -287,6 +287,7 @@ class MyModulesController < ApplicationController current_team, Constants::RECENT_PROTOCOL_LIMIT ).any? + @assigned_repositories = @my_module.assigned_repositories_list current_team_switch(@protocol.team) end diff --git a/app/models/my_module.rb b/app/models/my_module.rb index a4d01c6f5..a18290c05 100644 --- a/app/models/my_module.rb +++ b/app/models/my_module.rb @@ -205,6 +205,15 @@ class MyModule < ApplicationRecord .count end + def assigned_repositories_list + my_module_repository_rows.joins(repository_row: :repository) + .select(' + repositories.name, + repositories.id, + COUNT(my_module_repository_rows.id) as rows_count + ').group('repositories.name, repositories.id') + end + def unassigned_users User.find_by_sql( "SELECT DISTINCT users.id, users.full_name FROM users " + diff --git a/app/views/my_modules/inventories/_inventories_list.html.erb b/app/views/my_modules/inventories/_inventories_list.html.erb new file mode 100644 index 000000000..c68d13b36 --- /dev/null +++ b/app/views/my_modules/inventories/_inventories_list.html.erb @@ -0,0 +1,24 @@ +
+ <% @assigned_repositories.each do |repository| %> + + <% end %> +
\ No newline at end of file diff --git a/app/views/my_modules/protocols.html.erb b/app/views/my_modules/protocols.html.erb index f5635d56a..c4ce0bee1 100644 --- a/app/views/my_modules/protocols.html.erb +++ b/app/views/my_modules/protocols.html.erb @@ -39,7 +39,7 @@
- ... + <%= render partial: "my_modules/inventories/inventories_list" %>