From 7b158d7935a4d068d5f6881682332a795f480e84 Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Tue, 23 May 2023 11:57:50 +0400 Subject: [PATCH 1/3] (A) label for archived projects, inventories and protocol tempates in breadcrumbs [SCI-8404] --- app/views/shared/navigation/_breadcrumbs.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/shared/navigation/_breadcrumbs.html.erb b/app/views/shared/navigation/_breadcrumbs.html.erb index 8182c2b8c..981b79036 100644 --- a/app/views/shared/navigation/_breadcrumbs.html.erb +++ b/app/views/shared/navigation/_breadcrumbs.html.erb @@ -1,6 +1,6 @@ <% if @breadcrumbs_items&.length %> <% archived_exists = @breadcrumbs_items.any? { |item| item[:archived] } %> - <% @breadcrumbs_items.each { |item| item[:label] = "(A) #{item[:label]}" if archived_exists } %> + <% @breadcrumbs_items.each { |item| item[:label] = "(A) #{item[:label]}" if archived_exists || request.fullpath.include?('archived') } %> <% shortened = @breadcrumbs_items.length > 4 %> <% if shortened %> @@ -58,6 +58,7 @@ <% end %> + <% last_item[:label] = "(A) #{last_item[:label]}" if request.fullpath.include?('archived') && !last_item[:label].include?("(A)") %> <%= last_item[:label] %> From e5539097555f693b1c14579c1b8dc1eb3935e36b Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Wed, 24 May 2023 02:52:26 +0400 Subject: [PATCH 2/3] moved logic to controllers & concern --- app/controllers/concerns/breadcrumbs.rb | 12 ++++++++++++ app/controllers/protocols_controller.rb | 8 ++++++++ app/controllers/repositories_controller.rb | 8 ++++++++ app/views/shared/navigation/_breadcrumbs.html.erb | 3 --- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/controllers/concerns/breadcrumbs.rb b/app/controllers/concerns/breadcrumbs.rb index 6c0473776..151bbcd50 100644 --- a/app/controllers/concerns/breadcrumbs.rb +++ b/app/controllers/concerns/breadcrumbs.rb @@ -31,6 +31,13 @@ module Breadcrumbs include_my_module(my_module) if my_module + archived_exists = @breadcrumbs_items.any? { |item| item[:archived] == true } + + if params[:view_mode] == 'archived' || archived_exists + @breadcrumbs_items.each do |item| + item[:label] = "(A) #{item[:label]}" + end + end @breadcrumbs_items end end @@ -60,4 +67,9 @@ module Breadcrumbs archived: my_module.archived? }) end + + def archived_state + archived_exists = @breadcrumbs_items.any? { |item| item[:archived] } + archived_exists || request.fullpath.include?('archived') + end end diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 6b38cf9b1..995b92f2a 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -1173,5 +1173,13 @@ class ProtocolsController < ApplicationController archived: @protocol.archived? }) end + + archived_exists = @breadcrumbs_items.any? { |item| item[:archived] == true } + + if params[:type] == 'archived' || archived_exists + @breadcrumbs_items.each do |item| + item[:label] = "(A) #{item[:label]}" + end + end end end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index aa8a24185..fbabb711a 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -542,5 +542,13 @@ class RepositoriesController < ApplicationController archived: @repository.archived? }) end + + archived_exists = @breadcrumbs_items.any? { |item| item[:archived] == true } + + if params[:archived] == 'true' || archived_exists + @breadcrumbs_items.each do |item| + item[:label] = "(A) #{item[:label]}" + end + end end end diff --git a/app/views/shared/navigation/_breadcrumbs.html.erb b/app/views/shared/navigation/_breadcrumbs.html.erb index 981b79036..7a49f7fcf 100644 --- a/app/views/shared/navigation/_breadcrumbs.html.erb +++ b/app/views/shared/navigation/_breadcrumbs.html.erb @@ -1,6 +1,4 @@ <% if @breadcrumbs_items&.length %> - <% archived_exists = @breadcrumbs_items.any? { |item| item[:archived] } %> - <% @breadcrumbs_items.each { |item| item[:label] = "(A) #{item[:label]}" if archived_exists || request.fullpath.include?('archived') } %> <% shortened = @breadcrumbs_items.length > 4 %> <% if shortened %> @@ -58,7 +56,6 @@ <% end %> - <% last_item[:label] = "(A) #{last_item[:label]}" if request.fullpath.include?('archived') && !last_item[:label].include?("(A)") %> <%= last_item[:label] %> From b20912c52e4580beb78873f9d38b8bca1b2ac689 Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Wed, 24 May 2023 02:54:05 +0400 Subject: [PATCH 3/3] removed unnecessary code --- app/controllers/concerns/breadcrumbs.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/controllers/concerns/breadcrumbs.rb b/app/controllers/concerns/breadcrumbs.rb index 151bbcd50..52377c252 100644 --- a/app/controllers/concerns/breadcrumbs.rb +++ b/app/controllers/concerns/breadcrumbs.rb @@ -67,9 +67,4 @@ module Breadcrumbs archived: my_module.archived? }) end - - def archived_state - archived_exists = @breadcrumbs_items.any? { |item| item[:archived] } - archived_exists || request.fullpath.include?('archived') - end end