Skip to content

Commit

Permalink
Fix Node search
Browse files Browse the repository at this point in the history
The param used for ransack is filter and not q
Also we need to safelist the page association.
  • Loading branch information
tvdeyen committed Nov 22, 2023
1 parent 8b4faa4 commit 47b9947
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/javascript/alchemy_admin/components/node_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RemoteSelect } from "./remote_select"
class NodeSelect extends RemoteSelect {
_searchQuery(term, page) {
return {
q: {
filter: {
name_or_page_name_cont: term,
...JSON.parse(this.queryParams)
},
Expand Down
4 changes: 4 additions & 0 deletions app/models/alchemy/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def available_menu_names

private

def searchable_alchemy_resource_associations
%w[page]
end

# Reads the element definitions file named +menus.yml+ from +config/alchemy/+ folder.
#
def read_definitions_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe("alchemy-node-select", () => {
})

it("should add the query parameter to the API call", () => {
expect(component.ajaxConfig.data("test").q.foo).toEqual("bar")
expect(component.ajaxConfig.data("test").filter.foo).toEqual("bar")
})
})
})

0 comments on commit 47b9947

Please sign in to comment.