From 828e56669890fe3326d6d579ba9cd2cd55eafa49 Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Fri, 23 Jun 2023 11:26:53 +0400 Subject: [PATCH 1/2] changed logic to accomodate templates unique design --- .../shared/navigation/_breadcrumbs.html.erb | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/app/views/shared/navigation/_breadcrumbs.html.erb b/app/views/shared/navigation/_breadcrumbs.html.erb index 4624e867f..b5ac402b5 100644 --- a/app/views/shared/navigation/_breadcrumbs.html.erb +++ b/app/views/shared/navigation/_breadcrumbs.html.erb @@ -44,37 +44,42 @@ <%= last_item[:label] %> <% else %> + <% last_item = @breadcrumbs_items.pop %> <% template_paths = [/^\/protocols\/\d+$/, /^\/label_templates\/\d+$/] %> - <% if template_paths.any? { |pattern| request.path.match?(pattern) }%> - <% last_breadcrumb_items = @breadcrumbs_items.pop(2) %> + + <% if template_paths.any? { |pattern| request.path.match?(pattern) } || ["/protocols", "/label_templates"].include?(request.path) %> + + <%= @breadcrumbs_items.first[:label] %> + + + " + alt="navigate next" + class="navigate_next"> + + <% @breadcrumbs_items.each do |item| %> + <%= next if @breadcrumbs_items.first == item%> + <%= link_to(item[:label], item[:url], + class: "breadcrumbs-link", + title: item[:label]) %> + + " + alt="navigate next" + class="navigate_next"> + + <% end %> <% else %> - <% last_item = @breadcrumbs_items.pop %> + <% @breadcrumbs_items.each do |item| %> + <%= link_to(item[:label], item[:url], + class: "breadcrumbs-link", + title: item[:label]) %> + + " + alt="navigate next" + class="navigate_next"> + + <% end %> <% end %> - <% @breadcrumbs_items.each do |item| %> - <%= link_to(item[:label], item[:url], - class: "breadcrumbs-link", - title: item[:label]) %> - - " - alt="navigate next" - class="navigate_next"> - - <% end %> - - <% if last_breadcrumb_items %> - - <%= last_breadcrumb_items.first[:label] %> - - - " - alt="navigate next" - class="navigate_next"> - - - <%= last_breadcrumb_items.last[:label] %> - - <% end %> <% if last_item %> <%= last_item[:label] %> From ef94a4f2bb572823b730a05ed0918cbba376657d Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Fri, 23 Jun 2023 13:39:54 +0400 Subject: [PATCH 2/2] logic refactor, url removal --- .../stylesheets/navigation/breadcrumbs.scss | 4 ++ app/controllers/label_templates_controller.rb | 1 - app/controllers/protocols_controller.rb | 1 - .../shared/navigation/_breadcrumbs.html.erb | 45 ++++++------------- 4 files changed, 17 insertions(+), 34 deletions(-) diff --git a/app/assets/stylesheets/navigation/breadcrumbs.scss b/app/assets/stylesheets/navigation/breadcrumbs.scss index 2918adaf6..d0b479989 100644 --- a/app/assets/stylesheets/navigation/breadcrumbs.scss +++ b/app/assets/stylesheets/navigation/breadcrumbs.scss @@ -19,6 +19,10 @@ &:last-child { color: var(--sn-grey); } + + &.plain-text { + color: var(--sn-grey); + } } .delimiter { diff --git a/app/controllers/label_templates_controller.rb b/app/controllers/label_templates_controller.rb index 27dcf7e79..bc5183b43 100644 --- a/app/controllers/label_templates_controller.rb +++ b/app/controllers/label_templates_controller.rb @@ -207,7 +207,6 @@ class LabelTemplatesController < ApplicationController @breadcrumbs_items.push({ label: t('breadcrumbs.templates'), - url: label_templates_path }) @breadcrumbs_items.push({ diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index d805a1a40..cb5a436cb 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -1164,7 +1164,6 @@ class ProtocolsController < ApplicationController @breadcrumbs_items.push({ label: t('breadcrumbs.templates'), - url: archived_branch ? protocols_path(type: :archived) : protocols_path, archived: archived_branch }) diff --git a/app/views/shared/navigation/_breadcrumbs.html.erb b/app/views/shared/navigation/_breadcrumbs.html.erb index b5ac402b5..791d1d144 100644 --- a/app/views/shared/navigation/_breadcrumbs.html.erb +++ b/app/views/shared/navigation/_breadcrumbs.html.erb @@ -45,45 +45,26 @@ <% else %> <% last_item = @breadcrumbs_items.pop %> - <% template_paths = [/^\/protocols\/\d+$/, /^\/label_templates\/\d+$/] %> + <% @breadcrumbs_items.each do |item| %> + <% if item[:url] %> + <%= link_to(item[:label], item[:url], + class: "breadcrumbs-link", + title: item[:label]) %> + <% else %> + <%= content_tag(:span, item[:label], + class: "breadcrumbs-link plain-text", + title: item[:label]) %> + <% end %> - <% if template_paths.any? { |pattern| request.path.match?(pattern) } || ["/protocols", "/label_templates"].include?(request.path) %> - - <%= @breadcrumbs_items.first[:label] %> - " alt="navigate next" class="navigate_next"> - <% @breadcrumbs_items.each do |item| %> - <%= next if @breadcrumbs_items.first == item%> - <%= link_to(item[:label], item[:url], - class: "breadcrumbs-link", - title: item[:label]) %> - - " - alt="navigate next" - class="navigate_next"> - - <% end %> - <% else %> - <% @breadcrumbs_items.each do |item| %> - <%= link_to(item[:label], item[:url], - class: "breadcrumbs-link", - title: item[:label]) %> - - " - alt="navigate next" - class="navigate_next"> - - <% end %> <% end %> - <% if last_item %> - - <%= last_item[:label] %> - - <% end %> + + <%= last_item[:label] %> + <% end %> <% end %>