Skip to content

Commit

Permalink
Allow deep-linking to tabs. Add breadcrumb to go back to source list
Browse files Browse the repository at this point in the history
...Hopefully does not re-open #671
  • Loading branch information
fbacall committed Sep 13, 2023
1 parent 5ca8a52 commit 20d5029
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ function reposition_tiles(container, tileClass){
}

document.addEventListener("turbolinks:load", function() {
// Show the tab associated with the window location hash (e.g. "#packages")
if (window.location.hash) {
var tab = $('ul.nav a[href="' + window.location.hash + '"]');
if (tab.length) {
// This terrible hack gets around the fact that event handlers in view templates get bound after the
// `tab.tab('show')` executes, so nothing happens.
setTimeout(function () { tab.tab("show"); }, 50);
}
}

// Disabled tabs
$(".nav-tabs li a[data-toggle='tooltip']").tooltip();
$(".nav-tabs li.disabled a").click(function (e) { e.preventDefault(); return false });
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def set_breadcrumbs
if @content_provider
add_base_breadcrumbs('content_providers')
add_show_breadcrumb(@content_provider)
add_breadcrumb 'Sources'
add_breadcrumb 'Sources', content_provider_path(@content_provider, anchor: 'sources')

if params[:id]
add_breadcrumb @source.title, content_provider_source_path(@content_provider, @source) if (@source && !@source.new_record?)
Expand Down

0 comments on commit 20d5029

Please sign in to comment.