Class: Spina::Admin::MediaPickerController
- Inherits:
-
AdminController
- Object
- ActionController::Base
- Spina::ApplicationController
- AdminController
- Spina::Admin::MediaPickerController
- Defined in:
- app/controllers/spina/admin/media_picker_controller.rb
Instance Method Summary collapse
Methods inherited from AdminController
Instance Method Details
#select ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/controllers/spina/admin/media_picker_controller.rb', line 23 def select if params[:multiple] @images = Image.where(id: params[:image_ids].split("-")) else @image = Image.find(params[:image_id]) end end |
#show ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/spina/admin/media_picker_controller.rb', line 6 def show if @media_folder.present? @images = @media_folder.images.page(params[:page]) else @images = Image.where(media_folder_id: nil).page(params[:page]) end if params[:selected_ids].present? ids = params[:selected_ids].map(&:to_i).join(', ') @images = @images.order(Arel.sql("CASE WHEN id IN(#{ids}) THEN 0 ELSE 1 END, created_at DESC")) else @images = @images.sorted end render params[:page].present? ? :infinite_scroll : :show end |