diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-12 16:33:12 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-12 16:33:12 +0200 |
| commit | 4ec70e5ecf792a56e868538738d6c7f63bb6cf24 (patch) | |
| tree | 45364f298ce21a7e47de619b7db79b9b77e4ebc1 /app/controllers/admin_controller.rb | |
| parent | 5803c59192b7fb05840d0b452eb64d9f997f3d8f (diff) | |
Add a grouped tag+node search endpoint for the upcoming dashboard
AdminController#dashboard_search returns tags and nodes as separate,
labeled groups (via ActsAsTaggableOn::Tag.named_like and
Node.editor_search) rather than the flat per-node list every existing
picker returns. initSearchPicker gains a renderResults callback option
that, when given, replaces the default per-node rendering entirely --
lets the dashboard render its two labeled groups without a second,
parallel picker implementation.
resultsHeaderHtml (the "Press Enter to see all results" hint) is now
threaded through as a third argument to renderResults, so a picker with
custom rendering can still show it -- previously only the default
per-node branch ever did.
Tags link straight to the existing /admin/nodes/tags/:tag view rather
than becoming an in-place filter chip.
Diffstat (limited to 'app/controllers/admin_controller.rb')
| -rw-r--r-- | app/controllers/admin_controller.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3c45c49..8445997 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb | |||
| @@ -49,6 +49,24 @@ class AdminController < ApplicationController | |||
| 49 | end | 49 | end |
| 50 | end | 50 | end |
| 51 | 51 | ||
| 52 | def dashboard_search | ||
| 53 | term = params[:search_term] | ||
| 54 | |||
| 55 | if term.blank? | ||
| 56 | render json: { tags: [], nodes: [] } | ||
| 57 | return | ||
| 58 | end | ||
| 59 | |||
| 60 | render json: { | ||
| 61 | tags: ActsAsTaggableOn::Tag.named_like(term).limit(5).map { |tag| | ||
| 62 | { name: tag.name, tag_path: tags_nodes_path(tags: tag.name) } | ||
| 63 | }, | ||
| 64 | nodes: Node.editor_search(term).limit(10).map { |node| | ||
| 65 | { node_id: node.id, title: node.title, unique_name: node.unique_name, node_path: node_path(node) } | ||
| 66 | } | ||
| 67 | } | ||
| 68 | end | ||
| 69 | |||
| 52 | def menu_search | 70 | def menu_search |
| 53 | if params[:search_term] == "Root" | 71 | if params[:search_term] == "Root" |
| 54 | @results = [Node.root] | 72 | @results = [Node.root] |
