Skip to content

Commit

Permalink
enhancement: extra params on global search
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Nov 12, 2024
1 parent ab973b6 commit 45f4842
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/javascript/js/controllers/search_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export default class extends Controller {
'clearButton',
]

static values = {
extraParams: Object,
}

debouncedFetch = debouncePromise(fetch, this.searchDebounce)

destroyMethod
Expand Down Expand Up @@ -256,6 +260,7 @@ export default class extends Controller {
...Object.fromEntries(new URLSearchParams(window.location.search)),
q: query,
global: false,
...this.extraParamsValue,
}

if (this.isGlobalSearch) {
Expand Down
2 changes: 1 addition & 1 deletion app/views/avo/partials/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render partial: "avo/partials/logo" %>
</div>
<div class="flex-1 flex items-center justify-between lg:justify-start space-x-2 sm:space-x-8 lg:px-2">
<%= render Avo::Pro::GlobalSearchComponent.new rescue nil %>
<%= render Avo::Pro::GlobalSearchComponent.new(resource:) if defined?(Avo::Pro::GlobalSearchComponent) %>
<div class="m-0">
<%= render partial: "avo/partials/header" %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/avo/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<body class="bg-application os-mac">
<div class="relative flex flex-1 w-full min-h-full" data-controller="sidebar" data-sidebar-open-value="<%= @sidebar_open %>">
<div class="flex-1 flex flex-col max-w-full">
<%= render partial: "avo/partials/navbar" %>
<%= render partial: "avo/partials/navbar", locals: { resource: @resource } %>
<div data-sidebar-target="mainArea" class="content-area flex-1 flex pt-16 relative <%= "sidebar-open" if @sidebar_open %>">
<div class="hidden lg:flex">
<%= render Avo::SidebarComponent.new sidebar_open: @sidebar_open %>
Expand Down

0 comments on commit 45f4842

Please sign in to comment.