trestleadmin / trestle-search Goto Github PK
View Code? Open in Web Editor NEWSearch plugin for the Trestle admin framework
Home Page: https://trestle.io
License: GNU Lesser General Public License v3.0
Search plugin for the Trestle admin framework
Home Page: https://trestle.io
License: GNU Lesser General Public License v3.0
I'm assuming this is the intended gem when you reference PgSearch but it's not 100% clear. Please link from the wiki page if so: https://github.com/Casecommons/pg_search
I just realized this probably applies to the other adapters as well..
Hi!
Would it be possible to define a custom placeholder for a search field ? It would allow you to have different placeholders on your different views, for example to describe the behaviour of each search bar.
Thank you !
Placeholder issue to begin working out the details of how advanced search / filters will work.
this is not working (nothing filtered)
collection do
Customer.order(name: :asc)
end
search do |q|
# puts "test" # when adding debugging statements this doesn't seem to be called
collection.where("name LIKE ?", "%#{q}%")
end
while this is actually doing the filter (if manually adding the q param)
collection do
Customer.order(name: :asc).where("name LIKE ?", "%#{params[:q]}%")
end
the infrastructure recognises the presence of the search block as a search input is shown. but i've added some debugging statement in the search block and it doesn't seem to be called ?
Using this gem within a Rails 6 application conflicts with Zeitwerk autoloader.
Add this lines to the Gemfile
of brand new Rails 6 application:
gem 'trestle'
gem 'trestle-search'
Run bundle exec rake test
and look at this deprecation message:
DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper, ActionText::TagHelper, Trestle::AvatarHelper, Trestle::ContainerHelper, Trestle::DisplayHelper, Trestle::FlashHelper, Trestle::FormHelper, Trestle::FormatHelper, Trestle::GridHelper, Trestle::HeadingsHelper, Trestle::HookHelper, Trestle::I18nHelper, Trestle::IconHelper, Trestle::NavigationHelper, Trestle::PaginationHelper, Trestle::PanelHelper, Trestle::ParamsHelper, Trestle::SortHelper, Trestle::StatusHelper, Trestle::TabHelper, Trestle::TableHelper, Trestle::TimestampHelper, Trestle::ToolbarsHelper, and Trestle::UrlHelper.
Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.
Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload ActionText::ContentHelper, for example,
the expected changes won't be reflected in that stale Module object.
These autoloaded constants have been unloaded.
Please, check the "Autoloading and Reloading Constants" guide for solutions.
(called from <main> at /Users/ledermann/Playground/trestle-test/config/environment.rb:5)
Using a project with Trestle but without the gem trestle-search
works fine.
Please rename config/locale to config/locales
Hi guys! I'm trying to implement a simple search bar into a Trestle tab but I can't find any documentation about how to do it!
Can you helpe?
I have a book/post table with author_id linking to author table (belongs_to :author).
I am trying to add the author's name in the search but I keep getting errors because it seems that the author table is not getting linked in the query.
I've tried to add the authors table as follows:
collection do
# Set the default order when manual sorting is not applied
Book.order(created_at: :desc).includes(:author)
end
collection do
model.includes(:author)
end
I've also tried to add in the author in the search query:
search do |query|
query ? collection.joins(:author).where("author.name ILIKE ?", "%#{query}%" ) : collection
end
However I keep getting errors such as:
PG::UndefinedTable: ERROR: missing FROM-clause entry for table "author"
LINE 1: ...s" ON "authors"."id" = "books"."author_id" WHERE (author.nam...
How can I perform a search on a linked table ?
As in the docs, I set a scope like
In Company.rb model
scope :staff_between, ->(from, to) { joins(:job_histories).group('companies.id').having("count(company_id) >= :from AND count(comapny_id) <= :to", from: from, to: to) }
so I can call inside companies_admin.rb
scope :small, -> { Company.staff_between(1, 10) }, label: "1 to 25 collaborators"
But the group() creates an unexpected bahaviour when the results are counted at display
Is there a way to circumvent that ? the count done to return the badge number gives an hash of results instead
My listing of authors has a book count column. I'd like to be to sort on that. I am trying:
column :books , sort: :books_count do |auth|
auth.books.count
end
I've tried to set it up as follows:
collection do
# Set the default order when manual sorting is not applied
Author.order(created_at: :desc).includes(:books)
end
collection do
model.includes(:books)
end
sort_column :books_count do |collection, order|
collection.joins(:books).merge(Book.order(count: order))
end
However, I am just not able to get the sort_column part correct.
Hi,
Not sure why but when I installed this gem and go to the admin pages, it will jump to the Users table (Devise gem) to authorise instead of the Administrators table.
As a consequence, a normal user (from Users table) can access to the Admin zone as long as he's logged in.
If I remove this gem from the Gemfile, everything is working perfectly.
Any way to do minor customizations to the search element, for example changing the placeholder?
After installing this gem, this does not work anymore (simplified code):
collection do
Order.all
end
scopes do
scope :my_orders, -> { collection }
end
The error is
wrong number of arguments (given 0, expected 1)
referencing to the call to collection
.
I worked around this by defining collection
globally:
collection = Order.all
scopes do
scope :my_orders, -> { collection }
end
But that's just a workaround.
Scopes and the search textfield work pretty well separately, but you can't join their results in a AND
clause.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.