/backend/app/controllers/spree/admin/return_index_controller.rb

https://gitlab.com/shinvdu/spree · Ruby · 28 lines · 23 code · 4 blank · 1 comment · 2 complexity · 33bfd18fd0b08a90bec9b285d2a287d2 MD5 · raw file

  1. module Spree
  2. module Admin
  3. class ReturnIndexController < BaseController
  4. def return_authorizations
  5. collection(Spree::ReturnAuthorization)
  6. respond_with(@collection)
  7. end
  8. def customer_returns
  9. collection(Spree::CustomerReturn)
  10. respond_with(@collection)
  11. end
  12. private
  13. def collection(resource)
  14. return @collection if @collection.present?
  15. params[:q] ||= {}
  16. @collection = resource.all
  17. # @search needs to be defined as this is passed to search_form_for
  18. @search = @collection.ransack(params[:q])
  19. per_page = params[:per_page] || Spree::Config[:admin_products_per_page]
  20. @collection = @search.result.order(created_at: :desc).page(params[:page]).per(per_page)
  21. end
  22. end
  23. end
  24. end