app/controllers/spina/admin/photos_controller.rb in spina-0.11.1 vs app/controllers/spina/admin/photos_controller.rb in spina-0.12.0
- old
+ new
@@ -1,12 +1,10 @@
module Spina
module Admin
class PhotosController < AdminController
before_action :set_breadcrumbs
- authorize_resource class: Photo
-
layout "spina/admin/media_library"
def index
add_breadcrumb I18n.t('spina.website.photos'), spina.admin_photos_path
@photos = Photo.sorted.page(params[:page])
@@ -16,29 +14,12 @@
def media_library
redirect_to spina.admin_photos_path
end
def create
- if photo_params[:files].present?
- @photos = photo_params[:files].map do |file|
- Photo.create!(file: file)
- end
- respond_to do |format|
- format.js do
- render :create_multiple
- end
- end
- else
- @photo = Photo.create!(photo_params)
- respond_to do |format|
- format.js do
- render params[:media_library] ? :create : :create_and_select
- end
- format.json do
- render json: { file_url: @photo.file_url }
- end
- end
+ @photos = photo_params[:files].map do |file|
+ Photo.create!(file: file)
end
end
def destroy
@photo = Photo.find(params[:id])
@@ -87,32 +68,32 @@
def insert_photo_collection
@photos = Photo.find(params[:photo_ids]) if params[:photo_ids].present?
end
- def wysihtml5_insert
- @photo = Photo.find(params[:photo_id])
+ def trix_insert
+ @photo = Photo.find(params[:photo_id])
end
-
- def wysihtml5_select
- @photos = Photo.sorted.page(params[:page])
- @photo = Photo.new
-
- if params[:page].present?
- render :wysihtml5_infinite_scroll
- else
- render :wysihtml5_select
- end
+
+ def trix_select
+ @photos = Photo.sorted.page(params[:page])
+ @photo = Photo.new
+
+ if params[:page].present?
+ render :trix_infinite_scroll
+ else
+ render :trix_select
+ end
end
private
def set_breadcrumbs
add_breadcrumb I18n.t('spina.website.media_library'), spina.admin_media_library_path
end
def photo_params
- params.require(:photo).permit(:file, files: [])
+ params.require(:photo).permit(files: [])
end
end
end
end