Class: Spina::Admin::PhotosController
Instance Method Summary
collapse
#current_admin_path
#current_account, #error_explanation!, #image_tag_with_at2x, #link_to_add_fields, #markdown
Instance Method Details
#create ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 20
def create
@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
end
|
#destroy ⇒ Object
32
33
34
35
36
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 32
def destroy
@photo = Photo.find(params[:id])
@photo.destroy
redirect_to spina.admin_photos_url
end
|
#enhance ⇒ Object
38
39
40
41
42
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 38
def enhance
@photo = Photo.find(params[:id])
@photo.remote_file_url = params[:new_image]
@photo.save
end
|
#index ⇒ Object
10
11
12
13
14
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 10
def index
add_breadcrumb I18n.t('spina.website.photos'), spina.admin_photos_path
@photos = Photo.sorted.page(params[:page])
@photo = Photo.new
end
|
#insert_photo ⇒ Object
73
74
75
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 73
def insert_photo
@photo = Photo.find(params[:photo_id]) if params[:photo_id].present?
end
|
#insert_photo_collection ⇒ Object
77
78
79
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 77
def insert_photo_collection
@photos = Photo.find(params[:photo_ids]) if params[:photo_ids].present?
end
|
#link ⇒ Object
44
45
46
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 44
def link
@photo = Photo.find(params[:id])
end
|
16
17
18
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 16
def media_library
redirect_to spina.admin_photos_path
end
|
#photo_collection_select ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 61
def photo_collection_select
@selected_photo_ids = Photo.where(id: params[:selected_photo_ids]).ids
@photos = Photo.order_by_ids(@selected_photo_ids).sorted.page(params[:page])
@photo = Photo.new
if params[:page].present?
render :multi_picker_infinite_scroll
else
render :photo_collection_select
end
end
|
#photo_select ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 48
def photo_select
@selected_photo_id = Photo.find_by(id: params[:selected_photo_id]).try(:id)
@hidden_field_id = params[:hidden_field_id]
@photos = Photo.order_by_ids(@selected_photo_id).sorted.page(params[:page])
@photo = Photo.new
if params[:page].present?
render :single_picker_infinite_scroll
else
render :photo_select
end
end
|
#wysihtml5_insert ⇒ Object
81
82
83
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 81
def wysihtml5_insert
@photo = Photo.find(params[:photo_id])
end
|
#wysihtml5_select ⇒ Object
85
86
87
88
89
90
91
92
93
94
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 85
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
end
|