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. --- public/javascripts/admin_search.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'public/javascripts/admin_search.js') diff --git a/public/javascripts/admin_search.js b/public/javascripts/admin_search.js index 78577e7..8ff0db1 100644 --- a/public/javascripts/admin_search.js +++ b/public/javascripts/admin_search.js @@ -18,14 +18,19 @@ admin_search = { } $("#search_term").bind("keyup", function() { - if ($(this).attr("value")) { + console.log("keyup fired, value:", $(this).val()); + if ($(this).val()) { + console.log("sending ajax to", ADMIN_SEARCH_URL); $.ajax({ type: "GET", - url: "/admin/search", - data: "search_term=" + $(this).attr("value"), + url: ADMIN_SEARCH_URL, + data: "search_term=" + $(this).val(), dataType: "json", success : function(results) { admin_search.show_results(results); + }, + error: function(xhr, status, error) { + console.log("Ajax error:", status, error, xhr.status, xhr.responseText); } }); } @@ -52,7 +57,7 @@ menu_items = { if ($(this).attr("value")) { $.ajax({ type: "GET", - url: "/admin/menu_search", + url: ADMIN_MENU_SEARCH_URL, data: "search_term=" + $(this).attr("value"), dataType: "json", success : function(results) { @@ -104,7 +109,7 @@ parent_search = { if ($(this).attr("value")) { $.ajax({ type: "GET", - url: "/admin/menu_search", + url: ADMIN_MENU_SEARCH_URL, data: "search_term=" + $(this).attr("value"), dataType: "json", success : function(results) { @@ -184,7 +189,7 @@ move_to_search = { if (_this.attr("value")) { $.ajax({ type: "GET", - url: "/admin/menu_search", + url: ADMIN_MENU_SEARCH_URL, data: "search_term=" + _this.attr("value"), dataType: "json", success : function(results) { -- cgit v1.3