From 191a77b2f7c280e00f7348507c13a173c704fcf9 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 29 Jun 2026 04:28:55 +0200 Subject: Restore and improve admin node search - Admin search broke when routing-filter was removed: hardcoded /admin/search and /admin/menu_search URLs in admin_search.js no longer matched the locale-scoped routes. Fix by emitting locale-aware URLs from the layout as JS variables. - Also fixes form submission (POST -> GET, missing = on form_tag), jQuery .attr("value") -> .val() for typeahead input reading, and template name for Rails 8 compatibility. - Adds a visible "search" link to the admin menu so editors can discover the feature without knowing the Alt+F shortcut. Search results now show node path alongside title and link directly to the edit view. Named route admin_menu_search added to routes.rb. --- app/controllers/admin_controller.rb | 4 ++-- app/views/admin/_menu.html.erb | 1 + app/views/admin/search_results.html.erb | 2 +- app/views/layouts/admin.html.erb | 6 +++++- config/routes.rb | 1 + public/javascripts/admin_search.js | 17 +++++++++++------ 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 9e8564e..1a94a77 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -35,12 +35,12 @@ class AdminController < ApplicationController respond_to do |format| format.html do - render :template => 'admin/search_results.html' + render :template => 'admin/search_results' end format.js do render( :json => @results.map do |node| if node - {:id => node.id, :title => node.title, :edit_path => node_path(node)} + {:id => node.id, :title => " #{node.title} (#{node.unique_name})", :edit_path => edit_node_path(node)} end end ) diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 6f217eb..6dba085 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -1,6 +1,7 @@ <%= language_selector %> <%= button_to 'Logout', logout_path, method: :delete %> <%= link_to 'Overview', admin_path %> +search <%= link_to 'Nodes', nodes_path, selected?('nodes') %> <%= link_to 'Assets', assets_path, selected?('assets') %> <%= link_to 'User', users_path, selected?('users') %> diff --git a/app/views/admin/search_results.html.erb b/app/views/admin/search_results.html.erb index 671b665..f8aece0 100644 --- a/app/views/admin/search_results.html.erb +++ b/app/views/admin/search_results.html.erb @@ -2,6 +2,6 @@ diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 890aeaa..c1cada3 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -13,6 +13,10 @@ + @@ -41,7 +45,7 @@