TrestleAdmin / trestle

A modern, responsive admin framework for Ruby on Rails
https://trestle.io
GNU Lesser General Public License v3.0
1.96k stars 177 forks source link

Listing dates per page #432

Closed Guih12 closed 1 year ago

Guih12 commented 1 year ago

Hello guys. How are you? Guys, i need a help. How i to implement a new component in dashboard of trestle?

My idea is to implement a component that have numbers to listing

See a example of like i want to implement image

I know that it is not nature of Treslte, but somebody can me help?

joshmn commented 1 year ago

The easiest way to do this is to want to copy app/views/trestle/resource/_scopes.html.erb from Trestle gem into your views folder and make the necessary changes, and then some real hacky stuff on the collection:

Trestle.resource(:movies) do 
  collection do
    admin.pagination_options[:per] = params[:per]
    Movie.all 
  end
end

Make sure that you're returning a relation in the collection block.