mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Search across the logbook, squawks, notes, ADs, documents, components, flights and major records (top bar)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8c8e3b7374
commit
2953b9a18d
7 files changed
+189
No files matched your search
@@ -36,6 +36,7 @@
|
||||
<div class="absolute right-0 z-30 mt-2 w-56 rounded-md bg-surface py-1 text-slate-700 shadow-lg ring-1 ring-slate-200">
|
||||
<p class="truncate px-4 pt-2 pb-1 text-xs text-slate-500"><%= current_user.email_address %></p>
|
||||
<%= link_to "Profile", edit_profile_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
|
||||
<%= link_to "Search", search_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
|
||||
<%= link_to "Help", help_path, class: "block px-4 py-2.5 hover:bg-slate-100" %>
|
||||
<% if current_user.admin? %>
|
||||
<p class="border-t border-slate-100 px-4 pt-2 pb-1 text-xs font-semibold text-slate-500">Admin</p>
|
||||
@@ -48,6 +49,11 @@
|
||||
</details>
|
||||
</nav>
|
||||
<nav class="hidden items-center gap-4 text-sm sm:flex" aria-label="Main">
|
||||
<%= form_with url: search_path, method: :get, class: "hidden md:block", html: { role: "search" } do %>
|
||||
<%= search_field_tag :q, params[:q], placeholder: "Search…", "aria-label": "Search the records",
|
||||
class: "w-40 rounded bg-white/10 px-2 py-1 text-sm text-white placeholder:text-white/60 focus:w-56 focus:bg-white/20 focus:outline-none transition-all lg:w-48" %>
|
||||
<% end %>
|
||||
<%= link_to "Search", search_path, class: "hover:text-sky-300 md:hidden" %>
|
||||
<%= link_to "Fleet", root_path, class: "hover:text-sky-300" %>
|
||||
<% if current_user.admin? %>
|
||||
<details class="relative" data-controller="dropdown" data-action="click@window->dropdown#closeOutside keydown.esc@window->dropdown#close">
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<% content_for :title, @search.query.present? ? "Search: #{@search.query}" : "Search" %>
|
||||
<h1 class="mb-4 text-2xl font-bold">Search</h1>
|
||||
<%= form_with url: search_path, method: :get, class: "card card-body mb-5 flex flex-wrap items-end gap-2", data: { turbo_action: "advance" } do %>
|
||||
<div class="min-w-0 flex-1">
|
||||
<%= label_tag :q, "Search for", class: "label" %>
|
||||
<%= search_field_tag :q, @search.query, class: "input", autofocus: @search.query.blank?, placeholder: "e.g. magneto, KOQU, 2011-10-09, oil filter" %>
|
||||
</div>
|
||||
<% if @fleet.size > 1 %>
|
||||
<div>
|
||||
<%= label_tag :aircraft_id, "Aircraft", class: "label" %>
|
||||
<%= select_tag :aircraft_id, options_for_select([ [ "All aircraft", "" ] ] + @fleet.map { [ _1.tail_number, _1.id ] }, @aircraft&.id), class: "input" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= submit_tag "Search", class: "btn-primary", name: nil %>
|
||||
<% end %>
|
||||
|
||||
<% if @search.query.present? && !@search.searchable? %>
|
||||
<p class="text-sm text-slate-600">Type at least two characters.</p>
|
||||
<% elsif @search.searchable? %>
|
||||
<p class="mb-3 text-sm text-slate-600" role="status"><%= pluralize(@search.count, "result") %> for “<%= @search.query %>”<%= " on #{@aircraft.tail_number}" if @aircraft %>.</p>
|
||||
<div class="space-y-5">
|
||||
<% @search.results.each do |kind, results| %>
|
||||
<section class="card">
|
||||
<div class="card-header"><h2 class="card-title"><%= SiteSearch::KINDS[kind] %> <span class="text-sm font-normal text-slate-500">(<%= results.size %><%= "+" if results.size >= SiteSearch::LIMIT %>)</span></h2></div>
|
||||
<ul class="divide-y divide-slate-100">
|
||||
<% results.each do |r| %>
|
||||
<li class="px-4 py-2">
|
||||
<%= link_to r.title, r.path, class: "link font-medium" %>
|
||||
<% if @fleet.size > 1 && !@aircraft %><span class="badge-gray ml-1"><%= r.aircraft&.tail_number %></span><% end %>
|
||||
<% if r.snippet %><p class="mt-0.5 text-sm text-slate-600"><%= highlight(r.snippet, @search.query, highlighter: '<mark class="rounded bg-amber-100 px-0.5 text-slate-900">\1</mark>') %></p><% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</section>
|
||||
<% end %>
|
||||
<% if @search.results.empty? %><div class="card"><%= empty_state "Nothing found. Try a shorter word, a part number or an airport code." %></div><% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
Reference in new issue
Block a user